Show the file name in the location if the file is included
This commit is contained in:
parent
85879f5380
commit
427a8886a1
@ -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;
|
||||
|
@ -425,9 +425,15 @@ failing_contracts() ->
|
||||
"The field `y` is missing when constructing an element of type `r(int)`">>,
|
||||
<<?Pos(6, 42)
|
||||
"The fields `y`, `z` are missing when constructing an element of type `r('a)`">>])
|
||||
, ?TYPE_ERROR(namespace_clash,
|
||||
, ?TYPE_ERROR(namespace_clash_builtin,
|
||||
[<<?Pos(4, 10)
|
||||
"The contract `Call` has the same name as a namespace at (builtin location)">>])
|
||||
, ?TYPE_ERROR(namespace_clash_included,
|
||||
[<<?Pos(5, 11)
|
||||
"The namespace `BLS12_381` has the same name as a namespace at line 1, column 11 in BLS12_381.aes">>])
|
||||
, ?TYPE_ERROR(namespace_clash_same_file,
|
||||
[<<?Pos(4, 11)
|
||||
"The namespace `Nmsp` has the same name as a namespace at line 1, column 11">>])
|
||||
, ?TYPE_ERROR(bad_events,
|
||||
[<<?Pos(9, 25)
|
||||
"The indexed type `string` is not a word type">>,
|
||||
|
9
test/contracts/namespace_clash_included.aes
Normal file
9
test/contracts/namespace_clash_included.aes
Normal file
@ -0,0 +1,9 @@
|
||||
@compiler >= 6
|
||||
|
||||
include "BLS12_381.aes"
|
||||
|
||||
namespace BLS12_381 =
|
||||
type fp = int
|
||||
|
||||
main contract Bug =
|
||||
type number = int
|
8
test/contracts/namespace_clash_same_file.aes
Normal file
8
test/contracts/namespace_clash_same_file.aes
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Nmsp =
|
||||
type x = int
|
||||
|
||||
namespace Nmsp =
|
||||
type y = string
|
||||
|
||||
main contract Bug =
|
||||
type number = int
|
Loading…
x
Reference in New Issue
Block a user