Consider namespaces when collecting used_types
This commit is contained in:
parent
098dac65e2
commit
33dbeeefad
@ -611,11 +611,11 @@ infer_contract(Env, What, Defs) ->
|
||||
{Env4, TypeDefs ++ Decls ++ Defs1}.
|
||||
|
||||
-spec check_typedefs(env(), [aeso_syntax:decl()]) -> {env(), [aeso_syntax:decl()]}.
|
||||
check_typedefs(Env, Defs) ->
|
||||
check_typedefs(Env = #env{ namespace = Ns }, Defs) ->
|
||||
create_type_errors(),
|
||||
GetName = fun({type_def, _, {id, _, Name}, _, _}) -> Name end,
|
||||
TypeMap = maps:from_list([ {GetName(Def), Def} || Def <- Defs ]),
|
||||
DepGraph = maps:map(fun(_, Def) -> aeso_syntax_utils:used_types(Def) end, TypeMap),
|
||||
DepGraph = maps:map(fun(_, Def) -> aeso_syntax_utils:used_types(Ns, Def) end, TypeMap),
|
||||
SCCs = aeso_utils:scc(DepGraph),
|
||||
{Env1, Defs1} = check_typedef_sccs(Env, TypeMap, SCCs, []),
|
||||
destroy_and_report_type_errors(Env),
|
||||
|
@ -6,7 +6,7 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(aeso_syntax_utils).
|
||||
|
||||
-export([used_ids/1, used_types/1, used/1]).
|
||||
-export([used_ids/1, used_types/2, used/1]).
|
||||
|
||||
-record(alg, {zero, plus, scoped}).
|
||||
|
||||
@ -100,8 +100,12 @@ fold(Alg = #alg{zero = Zero, plus = Plus, scoped = Scoped}, Fun, K, X) ->
|
||||
used_ids(E) ->
|
||||
[ X || {{term, [X]}, _} <- used(E) ].
|
||||
|
||||
used_types(T) ->
|
||||
[ X || {{type, [X]}, _} <- used(T) ].
|
||||
used_types([Top] = _CurrentNS, T) ->
|
||||
F = fun({{type, [X]}, _}) -> [X];
|
||||
({{type, [Top1, X]}, _}) when Top1 == Top -> [X];
|
||||
(_) -> []
|
||||
end,
|
||||
lists:flatmap(F, used(T)).
|
||||
|
||||
-type entity() :: {term, [string()]}
|
||||
| {type, [string()]}
|
||||
|
Loading…
x
Reference in New Issue
Block a user