Bad error message reported when -XBinaryLiterals is not enabled
When -XBinaryLiterals
is not enabled, expressions like 0b10101
is causing
this horrible error message: Not in scope: ‘b10101’
.
The reason, as far as I understand, is that lexer is not lexing 0b0101
as a
single token when -XBinaryLiterals
is not enabled. Then the parser is parsing
this as an application of 0
to b0101
. (this can be observed with
-ddump-parsed
)
My suggestion:
Lexer should always generate a single token for 0b0101
. We don't do
ifExtension binaryLiteralsEnabled
checks in the lexer anymore. We somehow
mark generated token as "requires extension: BinaryLiterals"(I don't know if we
have the infrastructure for this right now). Then, when the parser sees an
integer that requires -XBinaryLiterals
, checks the flag and reports the error
etc.
Trac metadata
Trac field | Value |
---|---|
Version | 7.11 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Parser) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |