mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix internal compiler error when parsing `var
` declaration without identifier.
This commit is contained in:
parent
c3dc67d0e0
commit
6862f22943
@ -31,6 +31,7 @@ Bugfixes:
|
||||
* Commandline interface: Support ``--evm-version constantinople`` properly.
|
||||
* DocString Parser: Fix error message for empty descriptions.
|
||||
* Gas Estimator: Correctly ignore costs of fallback function for other functions.
|
||||
* Parser: Fix internal compiler error when parsing ``var`` declaration without identifier.
|
||||
* Parser: Fix parsing of getters for function type variables.
|
||||
* Standard JSON: Support ``constantinople`` as ``evmVersion`` properly.
|
||||
* Type Checker: Fix detection of recursive structs.
|
||||
|
@ -607,8 +607,10 @@ ASTPointer<VariableDeclaration> Parser::parseVariableDeclaration(
|
||||
if (_options.allowEmptyName && m_scanner->currentToken() != Token::Identifier)
|
||||
{
|
||||
identifier = make_shared<ASTString>("");
|
||||
solAssert(type != nullptr, "");
|
||||
nodeFactory.setEndPositionFromNode(type);
|
||||
solAssert(!_options.allowVar, ""); // allowEmptyName && allowVar makes no sense
|
||||
if (type)
|
||||
nodeFactory.setEndPositionFromNode(type);
|
||||
// if type is null this has already caused an error
|
||||
}
|
||||
else
|
||||
identifier = expectIdentifierToken();
|
||||
|
@ -557,16 +557,6 @@ BOOST_AUTO_TEST_CASE(variable_definition_with_initialization)
|
||||
BOOST_CHECK(successParse(text));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(variable_definition_in_function_parameter)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function fun(var a) {}
|
||||
}
|
||||
)";
|
||||
CHECK_PARSE_ERROR(text, "Expected explicit type name");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(variable_definition_in_mapping)
|
||||
{
|
||||
char const* text = R"(
|
||||
@ -579,18 +569,6 @@ BOOST_AUTO_TEST_CASE(variable_definition_in_mapping)
|
||||
CHECK_PARSE_ERROR(text, "Expected elementary type name for mapping key type");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(variable_definition_in_function_return)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract test {
|
||||
function fun() returns(var d) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_PARSE_ERROR(text, "Expected explicit type name");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(operator_expression)
|
||||
{
|
||||
char const* text = R"(
|
||||
|
13
test/libsolidity/syntaxTests/parsing/return_var.sol
Normal file
13
test/libsolidity/syntaxTests/parsing/return_var.sol
Normal file
@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f() returns(var) {}
|
||||
function f() returns(var x) {}
|
||||
function f() public pure returns (var storage) {}
|
||||
function f() public pure returns (var storage x) {}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (38-38): Expected explicit type name.
|
||||
// ParserError: (71-71): Expected explicit type name.
|
||||
// ParserError: (119-119): Expected explicit type name.
|
||||
// ParserError: (123-123): Location specifier needs explicit type name.
|
||||
// ParserError: (173-173): Expected explicit type name.
|
||||
// ParserError: (177-177): Location specifier needs explicit type name.
|
@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f(var) public pure {}
|
||||
function f(var x) public pure {}
|
||||
function f(var storage) public pure {}
|
||||
function f(var storage x) public pure {}
|
||||
}
|
||||
// ----
|
||||
// ParserError: (28-28): Expected explicit type name.
|
||||
// ParserError: (63-63): Expected explicit type name.
|
||||
// ParserError: (100-100): Expected explicit type name.
|
||||
// ParserError: (104-104): Location specifier needs explicit type name.
|
||||
// ParserError: (143-143): Expected explicit type name.
|
||||
// ParserError: (147-147): Location specifier needs explicit type name.
|
Loading…
Reference in New Issue
Block a user