ANN m_bool env_access(const Env env, const ae_flag flag, const loc_t pos) {
if (env->scope->depth) {
if (GET(flag, ae_flag_global))
- ERR_B(pos, _("'global' can only be used at %s scope."),
+ ERR_B(pos, _("`{G}global{0}` can only be used at %s scope."),
GET(flag, ae_flag_global) && !env->class_def ? "file" : "class")
}
if ((GET(flag, ae_flag_static) || GET(flag, ae_flag_private) ||
GET(flag, ae_flag_protect)) &&
(!env->class_def || env->scope->depth))
- ERR_B(pos, _("static/private/protect can only be used at class scope."))
+ ERR_B(pos, _("`{G}static/private/protect{0}` can only be used at class scope."))
return GW_OK;
}
ANN m_bool env_storage(const Env env, ae_flag flag, const loc_t pos) {
CHECK_BB(env_access(env, flag, pos));
- return !(env->class_def && GET(flag, ae_flag_global)) ? GW_OK : GW_ERROR;
+ if(env->class_def && GET(flag, ae_flag_global))
+ ERR_B(pos, _("`{G}global{0}` at class scope only valid for function pointers"));
+ return GW_OK;
}
#undef GET
}
ANN static inline m_bool scan1_exp_unary(const restrict Env env,
- const Exp_Unary * unary) {
+ Exp_Unary *const unary) {
if (unary->unary_type == unary_code) {
- RET_NSPC(scan1_stmt(env, unary->code))
+ const loc_t pos = exp_self(unary)->pos;
+ const Symbol sym = lambda_name(env->gwion->st, pos.first);
+ Exp lambda = new_exp_lambda(env->gwion->mp, sym, NULL, unary->code, pos);
+ mp_free(env->gwion->mp, Stmt, unary->code);
+ unary->exp = new_exp_call(env->gwion->mp, lambda, NULL, pos);
+ unary->unary_type = unary_exp;
}
return unary->unary_type == unary_exp ? scan1_exp(env, unary->exp) : GW_OK;
}
}
ANN static m_bool scan2_exp_unary(const Env env, const Exp_Unary *unary) {
- if (unary->unary_type == unary_code) {
- RET_NSPC(scan2_stmt(env, unary->code))
- } else if (unary->unary_type == unary_exp)
+ if (unary->unary_type == unary_exp)
return scan2_exp(env, unary->exp);
return GW_OK;
}
--- /dev/null
+#! [contains] at class scope only valid for function pointers
+class global C {
+ var global Event ev;
+}
-#! [contains] 'global' can only be used at class scope
+#! [contains] can only be used at class scope
class C {
{
var global int i;
-#! [contains] 'global' can only be used at file scope
+#! [contains] can only be used at file scope
{
var global int i;
}
-#! [contains] argument number does not match for lambda
+#! [contains] not enough arguments for lambda
\a b { <<< a, " ", b >>>; }(1);