diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 4ef4403..ead0fe6 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -3490,6 +3490,7 @@ pp_type(Label, Type) -> prettypr:format(prettypr:beside(prettypr:text(Label), aeso_pretty:type(Type, [show_generated])), 80, 80). src_file(T) -> aeso_syntax:get_ann(file, T, no_file). +include_type(T) -> aeso_syntax:get_ann(include_type, T, none). line_number(T) -> aeso_syntax:get_ann(line, T, 0). column_number(T) -> aeso_syntax:get_ann(col, T, 0). @@ -3497,13 +3498,16 @@ pos(T) -> aeso_errors:pos(src_file(T), line_number(T), column_number(T)). pos(L, C) -> aeso_errors:pos(L, C). loc(T) -> - {line_number(T), column_number(T)}. + {src_file(T), include_type(T), line_number(T), column_number(T)}. pp_loc(T) -> - {Line, Col} = loc(T), + {File, IncludeType, Line, Col} = loc(T), case {Line, Col} of {0, 0} -> "(builtin location)"; - _ -> io_lib:format("line ~p, column ~p", [Line, Col]) + _ -> case IncludeType of + none -> io_lib:format("line ~p, column ~p", [Line, Col]); + _ -> io_lib:format("line ~p, column ~p in ~s", [Line, Col, File]) + end end. plural(No, _Yes, [_]) -> No; diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index fa3cb6a..ae4f834 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -425,9 +425,15 @@ failing_contracts() -> "The field `y` is missing when constructing an element of type `r(int)`">>, <>]) - , ?TYPE_ERROR(namespace_clash, + , ?TYPE_ERROR(namespace_clash_builtin, [<>]) + , ?TYPE_ERROR(namespace_clash_included, + [<>]) + , ?TYPE_ERROR(namespace_clash_same_file, + [<>]) , ?TYPE_ERROR(bad_events, [<>, diff --git a/test/contracts/namespace_clash.aes b/test/contracts/namespace_clash_builtin.aes similarity index 100% rename from test/contracts/namespace_clash.aes rename to test/contracts/namespace_clash_builtin.aes diff --git a/test/contracts/namespace_clash_included.aes b/test/contracts/namespace_clash_included.aes new file mode 100644 index 0000000..bf2931d --- /dev/null +++ b/test/contracts/namespace_clash_included.aes @@ -0,0 +1,9 @@ +@compiler >= 6 + +include "BLS12_381.aes" + +namespace BLS12_381 = + type fp = int + +main contract Bug = + type number = int diff --git a/test/contracts/namespace_clash_same_file.aes b/test/contracts/namespace_clash_same_file.aes new file mode 100644 index 0000000..c969b18 --- /dev/null +++ b/test/contracts/namespace_clash_same_file.aes @@ -0,0 +1,8 @@ +namespace Nmsp = + type x = int + +namespace Nmsp = + type y = string + +main contract Bug = + type number = int