diff --git a/rebar.lock b/rebar.lock index 10be9f5..0cdb1c0 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,4 +1,4 @@ -{"1.1.0", +{"1.2.0", [{<<"aebytecode">>, {git,"https://github.com/aeternity/aebytecode.git", {ref,"0699f35b0398bac6cd4468da654d608375bd853d"}}, @@ -24,5 +24,8 @@ [ {pkg_hash,[ {<<"eblake2">>, <<"EC8AD20E438AAB3F2E8D5D118C366A0754219195F8A0F536587440F8F9BCF2EF">>}, - {<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>}]} + {<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>}]}, +{pkg_hash_ext,[ + {<<"eblake2">>, <<"3C4D300A91845B25D501929A26AC2E6F7157480846FAB2347A4C11AE52E08A99">>}, + {<<"getopt">>, <<"53E1AB83B9CEB65C9672D3E7A35B8092E9BDC9B3EE80721471A161C10C59959C">>}]} ]. diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 92a9d10..4a6fa5c 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -14,8 +14,13 @@ -export([ infer/1 , infer/2 + , unfold_types_in_type/2 , unfold_types_in_type/3 + , switch_scope/2 , pp_type/2 + , lookup_env1/4 + , name/1 + , qname/1 ]). -include("aeso_utils.hrl"). @@ -159,6 +164,10 @@ %% -- Environment manipulation ----------------------------------------------- +-spec switch_scope(qname(), env()) -> env(). +switch_scope(Scope, Env) -> + Env#env{namespace = Scope}. + -spec push_scope(namespace | contract, aeso_syntax:con(), env()) -> env(). push_scope(Kind, Con, Env) -> Ann = aeso_syntax:get_ann(Con), @@ -403,7 +412,7 @@ lookup_env(Env, Kind, Ann, Name) -> end end. --spec lookup_env1(env(), type | term, aeso_syntax:ann(), qname()) -> false | {qname(), fun_info()}. +-spec lookup_env1(env(), type | term, aeso_syntax:ann(), qname()) -> false | {qname(), fun_info() | type_info()}. lookup_env1(#env{ namespace = Current, used_namespaces = UsedNamespaces, scopes = Scopes }, Kind, Ann, QName) -> Qual = lists:droplast(QName), Name = lists:last(QName), @@ -1586,13 +1595,13 @@ app_t(Ann, Name, Args) -> {app_t, Ann, Name, Args}. lookup_name(Env, As, Name) -> lookup_name(Env, As, Name, []). -lookup_name(Env = #env{ namespace = NS, current_function = {id, _, Fun} = CurFn }, As, Id, Options) -> +lookup_name(Env = #env{ namespace = NS, current_function = CurFn }, As, Id, Options) -> case lookup_env(Env, term, As, qname(Id)) of false -> type_error({unbound_variable, Id}), {Id, fresh_uvar(As)}; {QId, {_, Ty}} -> - when_warning(warn_unused_variables, fun() -> used_variable(NS, Fun, QId) end), + when_warning(warn_unused_variables, fun() -> used_variable(NS, name(CurFn), QId) end), when_warning(warn_unused_functions, fun() -> register_function_call(NS ++ qname(CurFn), QId) end), Freshen = proplists:get_value(freshen, Options, false), diff --git a/src/aeso_syntax.erl b/src/aeso_syntax.erl index fbf4a6b..c6c0c9d 100644 --- a/src/aeso_syntax.erl +++ b/src/aeso_syntax.erl @@ -26,7 +26,7 @@ -type ann_format() :: '?:' | hex | infix | prefix | elif. -type ann() :: [ {line, ann_line()} | {col, ann_col()} | {format, ann_format()} | {origin, ann_origin()} - | stateful | private | payable | main | interface]. + | stateful | private | payable | main | interface | entrypoint]. -type name() :: string(). -type id() :: {id, ann(), name()}. @@ -42,6 +42,7 @@ | {contract_child, ann(), con(), [con()], [decl()]} | {contract_interface, ann(), con(), [con()], [decl()]} | {namespace, ann(), con(), [decl()]} + | {include, ann(), {string, ann(), string()}} | {pragma, ann(), pragma()} | {type_decl, ann(), id(), [tvar()]} % Only for error msgs | {type_def, ann(), id(), [tvar()], typedef()}