From 21647d3e7f18b944b4af80f479dc2178b203bd67 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Thu, 23 Jan 2020 18:01:25 +0100 Subject: [PATCH] fixup! check for repeat --- libsolidity/analysis/TypeChecker.cpp | 21 +++++++------------ .../functionCalls/calloptions_repeated.sol | 2 +- .../new_with_calloptions_unsupported.sol | 6 +++--- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 66a29954bf68..82a362989b42 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2237,9 +2237,9 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) return false; } - bool setSalt = false; expressionFunctionType->saltSet(); - bool setValue = false; expressionFunctionType->valueSet(); - bool setGas = false ;expressionFunctionType->gasSet(); + bool setSalt = false; + bool setValue = false; + bool setGas = false; FunctionType::Kind kind = expressionFunctionType->kind(); if ( @@ -2260,7 +2260,7 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) auto setCheckOption = [&](bool& _option, string const&& _name, bool _alreadySet = false) { - if (_option) + if (_option || _alreadySet) m_errorReporter.typeError( _functionCallOptions.location(), _alreadySet ? @@ -2278,7 +2278,7 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) { if (kind == FunctionType::Kind::Creation) { - setCheckOption(setSalt, "salt"); + setCheckOption(setSalt, "salt", expressionFunctionType->saltSet()); expectType(*_functionCallOptions.options()[i], *TypeProvider::fixedBytes(32)); } else @@ -2308,7 +2308,7 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) { expectType(*_functionCallOptions.options()[i], *TypeProvider::uint256()); - setCheckOption(setValue, "value"); + setCheckOption(setValue, "value", expressionFunctionType->valueSet()); } } else if (name == "gas") @@ -2322,7 +2322,7 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) { expectType(*_functionCallOptions.options()[i], *TypeProvider::uint256()); - setCheckOption(setGas, "gas"); + setCheckOption(setGas, "gas", expressionFunctionType->gasSet()); } } else @@ -2332,13 +2332,6 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions) ); } - if (expressionFunctionType->gasSet()) - setCheckOption(setGas, "gas", true); - if (expressionFunctionType->valueSet()) - setCheckOption(setValue, "value", true); - if (expressionFunctionType->saltSet()) - setCheckOption(setSalt, "salt", true); - if (setSalt && !m_evmVersion.hasCreate2()) m_errorReporter.typeError( _functionCallOptions.location(), diff --git a/test/libsolidity/syntaxTests/functionCalls/calloptions_repeated.sol b/test/libsolidity/syntaxTests/functionCalls/calloptions_repeated.sol index ba46d0341374..2ffe4b3edffe 100644 --- a/test/libsolidity/syntaxTests/functionCalls/calloptions_repeated.sol +++ b/test/libsolidity/syntaxTests/functionCalls/calloptions_repeated.sol @@ -16,6 +16,6 @@ contract C { // TypeError: (120-154): Option "gas" has already been set. // TypeError: (164-198): Option "value" has already been set. // TypeError: (208-242): Option "value" has already been set. -// TypeError: (252-293): Option "gas" has already been set. // TypeError: (252-293): Option "value" has already been set. +// TypeError: (252-293): Option "gas" has already been set. // TypeError: (303-330): Option "salt" has already been set. diff --git a/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions_unsupported.sol b/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions_unsupported.sol index 4c1cbaf3adb8..a9e873ef9a30 100644 --- a/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions_unsupported.sol +++ b/test/libsolidity/syntaxTests/functionCalls/new_with_calloptions_unsupported.sol @@ -10,6 +10,6 @@ contract C { // ==== // EVMVersion: