Skip to content

[5.8] Parse 0.2 after as float literal, not member access #1303

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

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Feb 1, 2023

Cherry-pick #1277 to release/5.8.


Deciding whether 0.2 should be lexed as a float literal or a member access is a little more difficult than just looking at the previous character because 0.2 might be preceeded by an operator like or .^., in which case it should be lexed as a float literal and not a member access.

We might be able to do some disambiguation magic on whether the character before the period is also an operator continuation point but that seems fairly brittle to me. The sanest way of doing this, is to store the previously lexed token’s kind in the cursor and checking that.

I measured and did not see a performance regregssion when parsing MovieSwiftUI.

rdar://103273988

Deciding whether `0.2` should be lexed as a float literal or a member access is a little more difficult than just looking at the previous character because `0.2` might be preceeded by an operator like `…` or `.^.`, in which case it should be lexed as a float literal and not a member access.

We might be able to do some disambiguation magic on whether the character before the period is also an operator continuation point but that seems fairly brittle to me. The sanest way of doing this, is to store the previously lexed token’s kind in the cursor and checking that.

I measured and did not see a performance regregssion when parsing MovieSwiftUI.

rdar://103273988
@ahoppen ahoppen changed the title Parse 0.2 after as float literal, not member access [5.8] Parse 0.2 after as float literal, not member access Feb 1, 2023
@ahoppen
Copy link
Member Author

ahoppen commented Feb 1, 2023

@swift-ci Please test

@ahoppen ahoppen merged commit dc1a32f into swiftlang:release/5.8 Feb 2, 2023
@ahoppen ahoppen deleted the ahoppen/5.8-lexing-error branch February 2, 2023 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants