From 6c0a3bd0430fb0ddb1f1742931274c4f9d5950f6 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Thu, 5 Nov 2020 01:38:57 +0000 Subject: [PATCH] Ensure that builtins must be executed --- libyul/AsmParser.cpp | 2 ++ .../syntaxTests/inlineAssembly/assignment_from_opcode_like.sol | 2 +- test/libyul/yulSyntaxTests/builtin_identifier_3.yul | 2 +- test/libyul/yulSyntaxTests/for_expr_invalid_5.yul | 3 +-- test/libyul/yulSyntaxTests/functional_partial.yul | 2 +- test/libyul/yulSyntaxTests/if_statement_invalid_1.yul | 3 +-- test/libyul/yulSyntaxTests/if_statement_invalid_4.yul | 3 +-- test/libyul/yulSyntaxTests/switch_invalid_expr_2.yul | 2 +- 8 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index e19f5b8ce..4dcc6b19a 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -256,6 +256,8 @@ Expression Parser::parseExpression() { if (currentToken() == Token::LParen) return parseCall(std::move(operation)); + else if (auto const& name = std::get(operation).name; m_dialect.builtin(name)) + fatalParserError(7104_error, "Builtin function \"" + name.str() + "\" must be called."); return std::get(operation); } else diff --git a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_opcode_like.sol b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_opcode_like.sol index e9d6f1983..306604931 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_opcode_like.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/assignment_from_opcode_like.sol @@ -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. diff --git a/test/libyul/yulSyntaxTests/builtin_identifier_3.yul b/test/libyul/yulSyntaxTests/builtin_identifier_3.yul index ece40e793..04236a8ba 100644 --- a/test/libyul/yulSyntaxTests/builtin_identifier_3.yul +++ b/test/libyul/yulSyntaxTests/builtin_identifier_3.yul @@ -2,4 +2,4 @@ function f(x) { f(add) } } // ---- -// DeclarationError 8198: (21-24): Identifier not found. +// ParserError 7104: (24-25): Builtin function "add" must be called. diff --git a/test/libyul/yulSyntaxTests/for_expr_invalid_5.yul b/test/libyul/yulSyntaxTests/for_expr_invalid_5.yul index 7f89fb3f4..44d8ad7c1 100644 --- a/test/libyul/yulSyntaxTests/for_expr_invalid_5.yul +++ b/test/libyul/yulSyntaxTests/for_expr_invalid_5.yul @@ -2,5 +2,4 @@ for {} mload {} {} } // ---- -// DeclarationError 8198: (10-15): Identifier not found. -// TypeError 1733: (10-15): Expected a value of boolean type "bool" but got "u256" +// ParserError 7104: (16-17): Builtin function "mload" must be called. diff --git a/test/libyul/yulSyntaxTests/functional_partial.yul b/test/libyul/yulSyntaxTests/functional_partial.yul index 5f65cb13f..1bf1c64d6 100644 --- a/test/libyul/yulSyntaxTests/functional_partial.yul +++ b/test/libyul/yulSyntaxTests/functional_partial.yul @@ -2,4 +2,4 @@ let x := byte } // ---- -// DeclarationError 8198: (15-19): Identifier not found. +// ParserError 7104: (20-21): Builtin function "byte" must be called. diff --git a/test/libyul/yulSyntaxTests/if_statement_invalid_1.yul b/test/libyul/yulSyntaxTests/if_statement_invalid_1.yul index 8d40479cd..ef5e5e4da 100644 --- a/test/libyul/yulSyntaxTests/if_statement_invalid_1.yul +++ b/test/libyul/yulSyntaxTests/if_statement_invalid_1.yul @@ -2,5 +2,4 @@ if mload {} } // ---- -// DeclarationError 8198: (9-14): Identifier not found. -// TypeError 1733: (9-14): Expected a value of boolean type "bool" but got "u256" +// ParserError 7104: (15-16): Builtin function "mload" must be called. diff --git a/test/libyul/yulSyntaxTests/if_statement_invalid_4.yul b/test/libyul/yulSyntaxTests/if_statement_invalid_4.yul index 546537203..757eab328 100644 --- a/test/libyul/yulSyntaxTests/if_statement_invalid_4.yul +++ b/test/libyul/yulSyntaxTests/if_statement_invalid_4.yul @@ -2,5 +2,4 @@ if calldatasize {} } // ---- -// DeclarationError 8198: (9-21): Identifier not found. -// TypeError 1733: (9-21): Expected a value of boolean type "bool" but got "u256" +// ParserError 7104: (22-23): Builtin function "calldatasize" must be called. diff --git a/test/libyul/yulSyntaxTests/switch_invalid_expr_2.yul b/test/libyul/yulSyntaxTests/switch_invalid_expr_2.yul index 905b9ed1f..0886db409 100644 --- a/test/libyul/yulSyntaxTests/switch_invalid_expr_2.yul +++ b/test/libyul/yulSyntaxTests/switch_invalid_expr_2.yul @@ -4,4 +4,4 @@ default {} } // ---- -// DeclarationError 8198: (13-18): Identifier not found. +// ParserError 7104: (23-27): Builtin function "mload" must be called.