Ensure that builtins must be executed

This commit is contained in:
Alex Beregszaszi 2020-11-05 01:38:57 +00:00 committed by chriseth
parent e2a756a705
commit 6c0a3bd043
8 changed files with 9 additions and 10 deletions

View File

@ -256,6 +256,8 @@ Expression Parser::parseExpression()
{ {
if (currentToken() == Token::LParen) if (currentToken() == Token::LParen)
return parseCall(std::move(operation)); return parseCall(std::move(operation));
else if (auto const& name = std::get<Identifier>(operation).name; m_dialect.builtin(name))
fatalParserError(7104_error, "Builtin function \"" + name.str() + "\" must be called.");
return std::get<Identifier>(operation); return std::get<Identifier>(operation);
} }
else else

View File

@ -7,4 +7,4 @@ contract C {
} }
} }
// ---- // ----
// Warning 8261: (52-62): Variable is shadowed in inline assembly by an instruction of the same name // ParserError 7104: (118-119): Builtin function "mload" must be called.

View File

@ -2,4 +2,4 @@
function f(x) { f(add) } function f(x) { f(add) }
} }
// ---- // ----
// DeclarationError 8198: (21-24): Identifier not found. // ParserError 7104: (24-25): Builtin function "add" must be called.

View File

@ -2,5 +2,4 @@
for {} mload {} {} for {} mload {} {}
} }
// ---- // ----
// DeclarationError 8198: (10-15): Identifier not found. // ParserError 7104: (16-17): Builtin function "mload" must be called.
// TypeError 1733: (10-15): Expected a value of boolean type "bool" but got "u256"

View File

@ -2,4 +2,4 @@
let x := byte let x := byte
} }
// ---- // ----
// DeclarationError 8198: (15-19): Identifier not found. // ParserError 7104: (20-21): Builtin function "byte" must be called.

View File

@ -2,5 +2,4 @@
if mload {} if mload {}
} }
// ---- // ----
// DeclarationError 8198: (9-14): Identifier not found. // ParserError 7104: (15-16): Builtin function "mload" must be called.
// TypeError 1733: (9-14): Expected a value of boolean type "bool" but got "u256"

View File

@ -2,5 +2,4 @@
if calldatasize {} if calldatasize {}
} }
// ---- // ----
// DeclarationError 8198: (9-21): Identifier not found. // ParserError 7104: (22-23): Builtin function "calldatasize" must be called.
// TypeError 1733: (9-21): Expected a value of boolean type "bool" but got "u256"

View File

@ -4,4 +4,4 @@
default {} default {}
} }
// ---- // ----
// DeclarationError 8198: (13-18): Identifier not found. // ParserError 7104: (23-27): Builtin function "mload" must be called.