From 775b834ee5c641ee78358f9a6088e0f6862a4056 Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Sat, 10 Dec 2022 13:32:48 +0300 Subject: [PATCH 1/3] Hide warning when calling with non-0 value arg --- src/aeso_ast_infer_types.erl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index db8e4e3..55ba29e 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -1718,10 +1718,14 @@ check_stateful(#env { current_function = Fun }, _Id, _Type) -> %% Hack: don't allow passing the 'value' named arg if not stateful. This only %% works since the user can't create functions with named arguments. -check_stateful_named_arg(#env{ stateful = false, current_function = Fun }, {id, _, "value"}, Default) -> +check_stateful_named_arg(#env{ stateful = Stateful, current_function = Fun }, {id, _, "value"}, Default) -> case Default of {int, _, 0} -> ok; - _ -> type_error({value_arg_not_allowed, Default, Fun}) + _ -> + case Stateful of + true -> when_warning(warn_unused_stateful, fun() -> used_stateful(Fun) end); + false -> type_error({value_arg_not_allowed, Default, Fun}) + end end; check_stateful_named_arg(_, _, _) -> ok. -- 2.30.2 From 36d8e5d871d3c18fbd9d856ff3dba50acccab2f6 Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Sat, 10 Dec 2022 13:44:21 +0300 Subject: [PATCH 2/3] Update the tests --- test/contracts/warnings.aes | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/contracts/warnings.aes b/test/contracts/warnings.aes index 5aa05ce..580d1d7 100644 --- a/test/contracts/warnings.aes +++ b/test/contracts/warnings.aes @@ -12,7 +12,7 @@ namespace UnusedNamespace = // Unused private function h() = 3 -contract Warnings = +main contract Warnings = type state = int @@ -58,3 +58,10 @@ namespace FunctionsAsArgs = private function inc(n : int) : int = n + 1 // Never used private function dec(n : int) : int = n - 1 + +contract Remote = + entrypoint id(_) = 0 + +contract C = + payable stateful entrypoint + call_missing_con() : int = (ct_1111111111111111111111111111112JF6Dz72 : Remote).id(value = 1, 0) -- 2.30.2 From 377e294c5f0e728b0ff9d78f834c5e045f72d527 Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Sat, 10 Dec 2022 13:46:24 +0300 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a926a1e..b2c6d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Type definitions serialised to ACI as `typedefs` field instead of `type_defs` to increase compatibility. - Check contracts and entrypoints modifiers when implementing interfaces. - Contracts can no longer be used as namespaces. +- Do not show unused stateful warning for functions that call other contracts with a non-zero value argument. ### Removed ### Fixed - Typechecker crashes if Chain.create or Chain.clone are used without arguments. -- 2.30.2