Improve Events error message + more tests

This commit is contained in:
Hans Svensson 2019-02-25 21:53:52 +01:00
parent 202a06a580
commit 7b474e439c
3 changed files with 7 additions and 3 deletions

View File

@ -1849,7 +1849,7 @@ pp_error({event_0_to_3_indexed_values, Constr}) ->
io_lib:format("The event constructor ~s (at ~s) has too many indexed values (max 3)\n", io_lib:format("The event constructor ~s (at ~s) has too many indexed values (max 3)\n",
[name(Constr), pp_loc(Constr)]); [name(Constr), pp_loc(Constr)]);
pp_error({event_0_to_1_string_values, Constr}) -> pp_error({event_0_to_1_string_values, Constr}) ->
io_lib:format("The event constructor ~s (at ~s) has too many string values (max 1)\n", io_lib:format("The event constructor ~s (at ~s) has too many non-indexed values (max 1)\n",
[name(Constr), pp_loc(Constr)]); [name(Constr), pp_loc(Constr)]);
pp_error({repeated_constructor, Cs}) -> pp_error({repeated_constructor, Cs}) ->
io_lib:format("Variant types must have distinct constructor names\n~s", io_lib:format("Variant types must have distinct constructor names\n~s",

View File

@ -202,8 +202,11 @@ failing_contracts() ->
<<"The indexed type string (at line 9, column 25) is not a word type">>, <<"The indexed type string (at line 9, column 25) is not a word type">>,
<<"The indexed type alias_string (at line 11, column 25) equals string which is not a word type">>]} <<"The indexed type alias_string (at line 11, column 25) equals string which is not a word type">>]}
, {"bad_events2", , {"bad_events2",
[<<"The event constructor BadEvent1 (at line 9, column 7) has too many string values (max 1)">>, [<<"The event constructor BadEvent1 (at line 9, column 7) has too many non-indexed values (max 1)">>,
<<"The event constructor BadEvent2 (at line 10, column 7) has too many indexed values (max 3)">>]} <<"The event constructor BadEvent2 (at line 10, column 7) has too many indexed values (max 3)">>,
<<"The event constructor BadEvent3 (at line 11, column 7) has too many non-indexed values (max 1)">>,
<<"The payload type address (at line 11, column 17) should be string">>,
<<"The payload type int (at line 11, column 26) should be string">>]}
, {"type_clash", , {"type_clash",
[<<"Cannot unify int\n" [<<"Cannot unify int\n"
" and string\n" " and string\n"

View File

@ -8,6 +8,7 @@ contract Events =
| Event2(alias_string, indexed alias_address) | Event2(alias_string, indexed alias_address)
| BadEvent1(string, string) | BadEvent1(string, string)
| BadEvent2(indexed int, indexed int, indexed int, indexed address) | BadEvent2(indexed int, indexed int, indexed int, indexed address)
| BadEvent3(address, int)
function f1(x : int, y : string) = function f1(x : int, y : string) =
Chain.event(Event1(x, x+1, y)) Chain.event(Event1(x, x+1, y))