From 1085f7bd86e3998338e4c35304c2aa9f9cbc403b Mon Sep 17 00:00:00 2001 From: radrow Date: Thu, 13 Feb 2020 12:08:05 +0100 Subject: [PATCH 1/3] Instant unification error on arguments count mismatch --- src/aeso_ast_infer_types.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index e5fcc68..868329c 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -2072,7 +2072,8 @@ unify1(_Env, {qcon, _, Name}, {qcon, _, Name}, _When) -> true; unify1(_Env, {bytes_t, _, Len}, {bytes_t, _, Len}, _When) -> true; -unify1(Env, {fun_t, _, Named1, Args1, Result1}, {fun_t, _, Named2, Args2, Result2}, When) -> +unify1(Env, {fun_t, _, Named1, Args1, Result1}, {fun_t, _, Named2, Args2, Result2}, When) + when length(Args1) == length(Args2) -> unify(Env, Named1, Named2, When) andalso unify(Env, Args1, Args2, When) andalso unify(Env, Result1, Result2, When); unify1(Env, {app_t, _, {Tag, _, F}, Args1}, {app_t, _, {Tag, _, F}, Args2}, When) -- 2.30.2 From f2af3f96f720c4d4590eed4e54ac118a2b99ede3 Mon Sep 17 00:00:00 2001 From: radrow Date: Thu, 20 Feb 2020 15:50:55 +0100 Subject: [PATCH 2/3] add testcase --- test/aeso_compiler_tests.erl | 22 ++++++++++++++++++++++ test/contracts/bad_number_of_args.aes | 5 +++++ 2 files changed, 27 insertions(+) create mode 100644 test/contracts/bad_number_of_args.aes diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index c45b9ec..ec75032 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -623,6 +623,28 @@ failing_contracts() -> "Empty record/map update\n" " r {}">> ]) + , ?TYPE_ERROR(bad_number_of_args, + [< unit\n" + " and (int) => 'a\n", + "when checking the application at line 3, column 39 of\n" + " f : () => unit\n" + "to arguments\n" + " 1 : int">>, + < 'e\n" + " and (int) => 'd\n" + "when checking the application at line 4, column 20 of\n" + " g : (int, string) => 'e\n" + "to arguments\n" + " 1 : int">>, + < 'c\n" + " and (string) => 'b\n" + "when checking the application at line 5, column 20 of\n" + " g : (int, string) => 'c\nto arguments\n" + " \"Litwo, ojczyzno moja\" : string">> + ]) ]. -define(Path(File), "code_errors/" ??File). diff --git a/test/contracts/bad_number_of_args.aes b/test/contracts/bad_number_of_args.aes new file mode 100644 index 0000000..e28f74d --- /dev/null +++ b/test/contracts/bad_number_of_args.aes @@ -0,0 +1,5 @@ +contract Test = + entrypoint f() = () + entrypoint g(x : int, y : string) = f(1) + entrypoint h() = g(1) + entrypoint i() = g("Litwo, ojczyzno moja") \ No newline at end of file -- 2.30.2 From e3055ef16836bb8e9610f19bf01bf7027bf875fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Rowicki?= <35342116+radrow@users.noreply.github.com> Date: Thu, 20 Feb 2020 15:51:49 +0100 Subject: [PATCH 3/3] Add newline --- test/contracts/bad_number_of_args.aes | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/contracts/bad_number_of_args.aes b/test/contracts/bad_number_of_args.aes index e28f74d..3571cae 100644 --- a/test/contracts/bad_number_of_args.aes +++ b/test/contracts/bad_number_of_args.aes @@ -2,4 +2,5 @@ contract Test = entrypoint f() = () entrypoint g(x : int, y : string) = f(1) entrypoint h() = g(1) - entrypoint i() = g("Litwo, ojczyzno moja") \ No newline at end of file + entrypoint i() = g("Litwo, ojczyzno moja") + -- 2.30.2