--- /dev/null
+#!fun global void global_func_err() { <<< _func__ >>>; }
+fun global void global_func_err<~A~>() { <<< _func__ >>>; }
--- /dev/null
+#! [contains] is errored
+#!global_func_err();
+global_func_err<~int~>();
class C {
-typedef void t_ptr();
-fun void test(t_ptr p) {
- <<< p >>>;
-}
-fun void test() {
-}
+ typedef void t_ptr();
+ typedef void t_ptr1(int);
+ fun void test(t_ptr p) {
+ <<< p >>>;
+ }
+ fun void test() {}
-test => test;
+ test => test;
+ test $ t_ptr;
+ \{ <<< __func__ >>>; } $ t_ptr;#!; => test;
+ \{ <<< __func__ >>>; } => test;
+ \a{} @=> t_ptr1 ptr1;
}
C c;
ANN static m_bool emit_lambda(const Emitter emit, const Exp_Lambda * lambda) {
CHECK_BB(emit_func_def(emit, lambda->def))
- if(GET_FLAG(lambda->def, member))
+ if(GET_FLAG(lambda->def, member) && !exp_self(lambda)->emit_var)
emit_add_instr(emit, RegPushMem);
regpushi(emit, (m_uint)lambda->def->base->func->code);
return GW_OK;
const m_bool ret = _check_lambda(env, l, def);
if(owner)
env_pop(env, scope);
- return ret;
+ if(ret < 0)
+ return GW_ERROR;
+ exp_self(l)->type = l->def->base->func->value_ref->type;
+ return GW_OK;
}
ANN static m_bool fptr_lambda(const Env env, struct FptrInfo *info) {
free_map(env->gwion->mp, (Map)map_at(&context->lbls, i));
map_release(&context->lbls);
}
- REM_REF(context, env->gwion);
+ REM_REF(context, env->gwion)
env->curr = (Nspc)vector_pop(&env->scope->nspc_stack);
}
if(e->type == env->gwion->type[et_lambda] && is_fptr(env->gwion, t)) {
const Type owner = nspc_lookup_type1(t->e->owner->parent,
insert_symbol(t->e->owner->name));
- return check_lambda(env, owner, &e->d.exp_lambda, t->e->d.func->def);
+ const m_bool ret = check_lambda(env, owner, &e->d.exp_lambda, t->e->d.func->def);
+ e->emit_var = 1;
+ return ret;
}
if(implicit)
return check_implicit(env, e, t);
const Func func = find_func_match(env, f, exp->args);
f->next = next;
if(func) {
- if(func->value_ref->from->ctx->error)
- ERR_O(exp_self(exp)->pos, _("function '%s' is errored"), func->name)
SET_FLAG(func, checked | ae_flag_template);
return func;
}
return check_exp_call_template(env, (Exp_Call*)exp);
const Func func = find_func_match(env, exp->func->type->e->d.func, exp->args);
if((exp_self(exp)->d.exp_call.m_func = func)) {
+ if(func->value_ref->from->ctx && func->value_ref->from->ctx->error)
+ ERR_O(exp_self(exp)->pos, _("function '%s' is errored"), func->name)
exp->func->type = func->value_ref->type;
return func->def->base->ret_type;
}
#include "instr.h"
#include "import.h"
#include "tuple.h"
+#include "context.h"
ANN static m_bool scan2_stmt(const Env, const Stmt);
ANN static m_bool scan2_stmt_list(const Env, Stmt_List);
t->e->tuple = NULL;
return t;
}
-
ANN2(1,2) static Value func_value(const Env env, const Func f,
const Value overload) {
const Type t = func_type(env, f);
const Value v = new_value(env->gwion->mp, t, t->name);
+ valuefrom(env, v->from);
CHECK_OO(scan2_func_assign(env, f->def, f, v))
if(!overload) {
ADD_REF(v);
}
ANN m_bool scan2_func_def(const Env env, const Func_Def f) {
+ if(GET_FLAG(f, global))
+ env->context->global = 1;
const m_uint scope = !GET_FLAG(f, global) ? env->scope->depth : env_push_global(env);
f->stack_depth = (env->class_def && !GET_FLAG(f, static) && !GET_FLAG(f, global)) ? SZ_INT : 0;
if(GET_FLAG(f, variadic))