From 5c40fb060c800297c1dfe9e941b94153e369ae9c Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 16 Dec 2020 12:17:13 +0100 Subject: [PATCH] Report illegal tokens in the Yul parser. --- libyul/AsmParser.cpp | 3 +++ .../syntaxTests/inlineAssembly/invalid/invalid_number.sol | 2 +- test/libyul/yulSyntaxTests/invalid/invalid_octal_number.yul | 2 +- .../invalid/unicode_comment_direction_override.sol | 2 +- .../invalid/unicode_string_direction_override.sol | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index c43066ee0..25b94157c 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -327,6 +327,9 @@ variant Parser::parseLiteralOrIdentifier() case Token::HexStringLiteral: fatalParserError(3772_error, "Hex literals are not valid in this context."); break; + case Token::Illegal: + fatalParserError(1465_error, "Illegal token: " + to_string(m_scanner->currentError())); + break; default: fatalParserError(1856_error, "Literal or identifier expected."); } diff --git a/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol b/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol index b894fc6b8..1ba49bc39 100644 --- a/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/invalid/invalid_number.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// ParserError 1856: (72-73): Literal or identifier expected. +// ParserError 1465: (72-73): Illegal token: Octal numbers not allowed. diff --git a/test/libyul/yulSyntaxTests/invalid/invalid_octal_number.yul b/test/libyul/yulSyntaxTests/invalid/invalid_octal_number.yul index c3b5e02c2..446c29315 100644 --- a/test/libyul/yulSyntaxTests/invalid/invalid_octal_number.yul +++ b/test/libyul/yulSyntaxTests/invalid/invalid_octal_number.yul @@ -2,4 +2,4 @@ let x := 0100 } // ---- -// ParserError 1856: (15-16): Literal or identifier expected. +// ParserError 1465: (15-16): Illegal token: Octal numbers not allowed. diff --git a/test/libyul/yulSyntaxTests/invalid/unicode_comment_direction_override.sol b/test/libyul/yulSyntaxTests/invalid/unicode_comment_direction_override.sol index dffb49ec3..7fb5547f7 100644 --- a/test/libyul/yulSyntaxTests/invalid/unicode_comment_direction_override.sol +++ b/test/libyul/yulSyntaxTests/invalid/unicode_comment_direction_override.sol @@ -3,4 +3,4 @@ // underflow ‬ } // ---- -// ParserError 1856: (19-32): Literal or identifier expected. +// ParserError 1465: (19-32): Illegal token: Unicode direction override underflow in comment or string literal. diff --git a/test/libyul/yulSyntaxTests/invalid/unicode_string_direction_override.sol b/test/libyul/yulSyntaxTests/invalid/unicode_string_direction_override.sol index ee4e95236..2dba69450 100644 --- a/test/libyul/yulSyntaxTests/invalid/unicode_string_direction_override.sol +++ b/test/libyul/yulSyntaxTests/invalid/unicode_string_direction_override.sol @@ -3,4 +3,4 @@ let s := unicode"underflow ‬"; } // ---- -// ParserError 1856: (35-47): Literal or identifier expected. +// ParserError 1465: (35-47): Illegal token: Invalid character in string.