Skip to content

Commit

Permalink
fixup! check for repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
Marenz committed Jan 23, 2020
1 parent a9cb83b commit 21647d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
21 changes: 7 additions & 14 deletions libsolidity/analysis/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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 ?
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ contract C {
// ====
// EVMVersion: <constantinople
// ----
// TypeError: (97-123): Unsupported call option "salt" (requires "constantinople" or newer).
// TypeError: (127-144): Unsupported call option "salt" (requires "constantinople" or newer).
// TypeError: (168-188): Unsupported call option "salt" (requires "constantinople" or newer).
// TypeError: (97-123): Unsupported call option "salt" (requires Constantinople-compatible VMs).
// TypeError: (127-144): Unsupported call option "salt" (requires Constantinople-compatible VMs).
// TypeError: (168-188): Unsupported call option "salt" (requires Constantinople-compatible VMs).

0 comments on commit 21647d3

Please # to comment.