From 2acff6c9b459b413a5a08b9ce4e652f2bcfd71cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 15 May 2022 16:16:53 +0200 Subject: [PATCH] :art: error if @gack does not print anything --- src/parse/scan1.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parse/scan1.c b/src/parse/scan1.c index b6c232c8..d64c1f66 100644 --- a/src/parse/scan1.c +++ b/src/parse/scan1.c @@ -182,8 +182,12 @@ ANN static m_bool scan1_range(const Env env, Range *range) { } ANN static inline m_bool scan1_prim(const Env env, const Exp_Primary *prim) { - if (prim->prim_type == ae_prim_hack || prim->prim_type == ae_prim_dict || prim->prim_type == ae_prim_interp) + if (prim->prim_type == ae_prim_dict || prim->prim_type == ae_prim_interp) return scan1_exp(env, prim->d.exp); + if (prim->prim_type == ae_prim_hack) { + if(env->func) env->func->weight = 1; // mark function has having gack + return scan1_exp(env, prim->d.exp); + } if (prim->prim_type == ae_prim_array && prim->d.array->exp) return scan1_exp(env, prim->d.array->exp); if (prim->prim_type == ae_prim_range) return scan1_range(env, prim->d.range); @@ -680,6 +684,8 @@ ANN static m_bool _scan1_func_def(const Env env, const Func_Def fdef) { --env->scope->depth; env->func = former; if (global) env_pop(env, scope); + if (fdef->base->xid == insert_symbol("@gack") && !fake.weight) + ERR_B(fdef->base->pos, "`@gack` operator not printing anything"); return ret; } -- 2.43.0