diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-04-17 20:28:47 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-05-04 19:39:37 +0800 |
commit | e3279d8af89c9b5e99e6bca206cb5ce6ef5b0291 (patch) | |
tree | d78f8594c7cc072b0998efcd94533e37008df3f9 | |
parent | 81d61ca086e8e45108b7989e7f1494d90077401e (diff) | |
download | dexon-solidity-e3279d8af89c9b5e99e6bca206cb5ce6ef5b0291.tar dexon-solidity-e3279d8af89c9b5e99e6bca206cb5ce6ef5b0291.tar.gz dexon-solidity-e3279d8af89c9b5e99e6bca206cb5ce6ef5b0291.tar.bz2 dexon-solidity-e3279d8af89c9b5e99e6bca206cb5ce6ef5b0291.tar.lz dexon-solidity-e3279d8af89c9b5e99e6bca206cb5ce6ef5b0291.tar.xz dexon-solidity-e3279d8af89c9b5e99e6bca206cb5ce6ef5b0291.tar.zst dexon-solidity-e3279d8af89c9b5e99e6bca206cb5ce6ef5b0291.zip |
Display nicer error messages in the parser (display tokens and not internal names)
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/parsing/ParserBase.cpp | 22 |
2 files changed, 12 insertions, 11 deletions
diff --git a/Changelog.md b/Changelog.md index 817365b9..737a11f1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,7 @@ Features: * Build System: Update internal dependency of jsoncpp to 1.8.4, which introduces more strictness and reduces memory usage. * Code Generator: Use native shift instructions on target Constantinople. * Optimizer: Remove unnecessary masking of the result of known short instructions (``ADDRESS``, ``CALLER``, ``ORIGIN`` and ``COINBASE``). + * Parser: Display nicer error messages by showing the actual tokens and not internal names. * Type Checker: Deprecate the ``years`` unit denomination and raise a warning for it (or an error as experimental 0.5.0 feature). * Type Checker: Make literals (without explicit type casting) an error for tight packing as experimental 0.5.0 feature. diff --git a/libsolidity/parsing/ParserBase.cpp b/libsolidity/parsing/ParserBase.cpp index 617a1779..1dd3bdd2 100644 --- a/libsolidity/parsing/ParserBase.cpp +++ b/libsolidity/parsing/ParserBase.cpp @@ -71,10 +71,10 @@ void ParserBase::expectToken(Token::Value _value, bool _advance) if (Token::isReservedKeyword(tok)) { fatalParserError( - string("Expected token ") + - string(Token::name(_value)) + - string(" got reserved keyword '") + - string(Token::name(tok)) + + string("Expected '") + + string(Token::toString(_value)) + + string("' but got reserved keyword '") + + string(Token::toString(tok)) + string("'") ); } @@ -82,19 +82,19 @@ void ParserBase::expectToken(Token::Value _value, bool _advance) { ElementaryTypeNameToken elemTypeName = m_scanner->currentElementaryTypeNameToken(); fatalParserError( - string("Expected token ") + - string(Token::name(_value)) + - string(" got '") + + string("Expected '") + + string(Token::toString(_value)) + + string("' but got '") + elemTypeName.toString() + string("'") ); } else fatalParserError( - string("Expected token ") + - string(Token::name(_value)) + - string(" got '") + - string(Token::name(m_scanner->currentToken())) + + string("Expected '") + + string(Token::toString(_value)) + + string("' but got '") + + string(Token::toString(m_scanner->currentToken())) + string("'") ); } |