-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #2060 Disallow uppercase radix prefixes and exponential notation #2061
Issue #2060 Disallow uppercase radix prefixes and exponential notation #2061
Conversation
@@ -133,14 +133,18 @@ exports.Lexer = class Lexer | |||
numberToken: -> | |||
return 0 unless match = NUMBER.exec @chunk | |||
number = match[0] | |||
if /[E]/.test number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/E/.test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Also noticed the exponent error was the only one that didn't reference the source of the error. I'll patch and push a new version.
LGTM |
This patch is adding a lot of explicit special-case error strings ... is the behavior (error message) poor if we simply fail to match the token as a number, and proceed with the lex? |
It would have been much easier to make the bin/coffee -bpe '0X0'
Error: Parse error on line 1: Unexpected 'IDENTIFIER' If I were new to CoffeeScript, I'd assume hex literals were disallowed. Or, I'd file a bug report against it.
|
I keep thinking about this. I know I'm framing this poorly, but Is there a good reason for not being explicit? |
No, the descriptive errors are necessary. |
Issue #2060 Disallow uppercase radix prefixes and exponential notation
Thanks for merging! @jashkenas, I was holding off on pushing a change @michaelficarra suggested until I heard back on the error messages: - if /[E]/.test number
- @error "exponential notation must be indicated with a lowercase 'e'"
+ if /E/.test number
+ @error "exponential notation '#{number}' must be indicated with a lowercase 'e'"
Seems like overkill to open a new pull request -- can that change be applied within GitHub? |
@geraldalewis: just push another commit to that branch and I'll merge it in. |
Sounds good -- will push shortly. Edit: Hmm... Pushed, but it's not updating here. |
Not updating because pull request has already been merged, just submit a new pull request, don't forget to mention #2061 in the new pull request so they'll be linked... |
Disallows uppercase radix prefixes and exponential notation.
I also tweaked the error code for octal literals.
Uppercase radix prefixes.
Uppercase exponential notation.
Deprecated octal literal notation.
0
-prefixed decimals.