Skip to content
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

Throw a parser error to disambiguate numeric literals followed by .(op) #11529

Closed
wants to merge 1 commit into from

Conversation

jakebolewski
Copy link
Member

This breaking change throws a parser error asking the user to
disambiguate the parsing of a numeric literal and dot operator with no
whitespace in between. We are consistent in how this is handled (always
favor the operator in parsing with no disambiguating whitespace), but
there was popular support that this should be special cased as it it
quite hard to track these subtle syntax errors down.

Closes #10920

@jakebolewski jakebolewski added needs decision A decision on this change is needed breaking This change will break code parser Language parsing and surface syntax labels Jun 2, 2015
@@ -280,7 +280,7 @@
(if (eqv? (peek-char port) #\.)
(begin (read-char port)
(if (dot-opchar? (peek-char port))
(io.ungetc port #\.)
(error "add disambiguating space between numeric literal and inflix dot operator")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infix

… operators

This *breaking* change throws a parser error asking the user to
disambiguate the parsing of a numeric literal and dot operator with no
whitespace in between.  We are consistent in how this is handled (always
favor the operator in parsing with no disambiguating whitespace), but
there was popular support that this should be special cased as it it
quite hard to track these subtle syntax errors down.

Closes #10920
@StefanKarpinski
Copy link
Member

I feel like it might be better to require at least one digit after a decimal point. I've always found the 1. syntax to be a little excessively terse.

@jakebolewski
Copy link
Member Author

I was curious how annoying this change would be as it has often been brought up. After trying it, I like our current behavior better as I feel the rule is much simpler and more generic, precedence in the parser is always given to the operator when parsing an identifier / number followed by an operator. Throwing an error here seems wrong when that is the generic rule.

I also agree that the best change would be to require at least one digit after the decimal point. @stevengj thought that idea was too drastic.

@jakebolewski
Copy link
Member Author

Throwing an error here also means things like [1,2,3:4...] no longer work without being disambiguated. You have no idea if 4... is 4... 4. (..) or (4.)... without looking an unreasonable amount of characters ahead.

@jakebolewski
Copy link
Member Author

I'm going to chalk this up to a failed experiment, now that I have a better understanding of the edge cases. If we want to move to requiring a digit after a decimal point to delimit floating point literals (a huge breaking change) #10920 could be better addressed. As this is not going to happen I feel we should preserve the behavior we have now.

@jakebolewski jakebolewski deleted the jcb/parseerr10920 branch June 4, 2015 02:23
@tkelman
Copy link
Contributor

tkelman commented Jun 4, 2015

As this is not going to happen

Why not? It should at least be considered, or has that already come and gone?

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 092dbd6 on jcb/parseerr10920 into ** on master**.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code needs decision A decision on this change is needed parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1.+im returns a Complex{Int}
4 participants