Fixed segfault occurring with accidentally unnamed variables.
This commit is contained in:
parent
17985e3b5a
commit
ec8007125f
@ -21,8 +21,15 @@ void parseAndAddUntypedVariableDeclaration(Context &context, ast::VariableDeclar
|
|||||||
auto &tokenizer = context.tokenizer;
|
auto &tokenizer = context.tokenizer;
|
||||||
|
|
||||||
tokenizer.expect<std::string>("?");
|
tokenizer.expect<std::string>("?");
|
||||||
|
const auto position = tokenizer.position();
|
||||||
|
|
||||||
auto variableName = tokenizer.getIdentifier();
|
auto variableName = tokenizer.getIdentifier();
|
||||||
assert(variableName != "-");
|
|
||||||
|
if (variableName == "" || variableName == "-")
|
||||||
|
{
|
||||||
|
tokenizer.seek(position);
|
||||||
|
throw ParserException(tokenizer.location(), "could not parse variable name");
|
||||||
|
}
|
||||||
|
|
||||||
variableDeclarations.emplace_back(std::make_unique<ast::VariableDeclaration>(std::move(variableName)));
|
variableDeclarations.emplace_back(std::make_unique<ast::VariableDeclaration>(std::move(variableName)));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user