Merge pull request #29 from aeternity/more_better_errors

Improve Events error message + more tests
This commit is contained in:
Hans Svensson 2019-02-26 16:21:35 +01:00 committed by GitHub
commit 7c95aafbb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -1864,7 +1864,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",
[name(Constr), pp_loc(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)]);
pp_error({repeated_constructor, Cs}) ->
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 alias_string (at line 11, column 25) equals string which is not a word type">>]}
, {"bad_events2",
[<<"The event constructor BadEvent1 (at line 9, column 7) has too many string values (max 1)">>,
<<"The event constructor BadEvent2 (at line 10, column 7) has too many indexed values (max 3)">>]}
[<<"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 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",
[<<"Cannot unify int\n"
" and string\n"

View File

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