diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index c15f8ba..8eb049a 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -193,10 +193,10 @@ bind_state(Env) -> Env1 = bind_funs([{"state", State}, {"put", {fun_t, Ann, [], [State], Unit}}], Env), - %% A bit of a hack: we bind Chain.event with the local event type. - Env2 = force_bind_fun("event", {fun_t, Ann, [], [Event], Unit}, - Env1#env{ namespace = ["Chain"] }), - Env2#env{ namespace = Env1#env.namespace }. + %% We bind Chain.event in a local 'Chain' namespace. + pop_scope( + bind_fun("event", {fun_t, Ann, [], [Event], Unit}, + push_scope(namespace, {con, Ann, "Chain"}, Env1))). -spec bind_field(name(), field_info(), env()) -> env(). bind_field(X, Info, Env = #env{ fields = Fields }) -> diff --git a/src/aeso_ast_to_icode.erl b/src/aeso_ast_to_icode.erl index e9dd732..a7fbbb3 100644 --- a/src/aeso_ast_to_icode.erl +++ b/src/aeso_ast_to_icode.erl @@ -140,7 +140,7 @@ ast_type(T, Icode) -> ast_body(?qid_app(["Chain","spend"], [To, Amount], _, _), Icode) -> prim_call(?PRIM_CALL_SPEND, ast_body(Amount, Icode), [ast_body(To, Icode)], [word], {tuple, []}); -ast_body(?qid_app(["Chain","event"], [Event], _, _), Icode) -> +ast_body(?qid_app([Con, "Chain", "event"], [Event], _, _), Icode = #{ contract_name := Con }) -> aeso_builtins:check_event_type(Icode), builtin_call({event, maps:get(event_type, Icode)}, [ast_body(Event, Icode)]);