Skip to content

[Parse] Fix minor bug in #sourceLocation on lex error #19344

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
Sep 19, 2018

Conversation

johnno1962
Copy link
Contributor

There seems to be a minor bug in the implementation of #sourceLocation when the directive is succeeded by token that gives an error during lexing. The error will be reported with the wrong location. This is because lexing of the next token occurs immediately on consuming the last token of the directive which is before the virtual file is set up to have the location take effect.

Resolved by moving consumption of directives last token to the end of the function.

Resolves SR-8772.

@johnno1962 johnno1962 force-pushed the source-location branch 2 times, most recently from 53c70cf to d7ecc8d Compare September 17, 2018 19:37
Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Thanks! I'd still like @rintaro or someone more parsery to confirm the actual fix, but I'm glad it's testable.

@rintaro
Copy link
Member

rintaro commented Sep 17, 2018

Thanks for working on this! This is definitely an improvement.
Unfortunately, I think, this is not perfect. Could you try this?

#sourceLocation(file: "test.swift", line: 1000)
0xG

When the parser is at ), the Lexer have already read 0xG for peekToken().
Do you want to tackle on this issue? Similar one is here: https://bugs.swift.org/browse/SR-3415
If you prefer not to do it on this PR, it's OK, I'll merge this.

@rintaro
Copy link
Member

rintaro commented Sep 17, 2018

@swift-ci Please smoke test

@johnno1962
Copy link
Contributor Author

I think I’ll leave the bug you mention for another day but I was looking at making the “file:" optional in #sourceLocation. Do you think that would be worthwhile? That also can be a exercise for another day. Merge away...

@rintaro
Copy link
Member

rintaro commented Sep 18, 2018

@swift-ci Please smoke test

@johnno1962 johnno1962 force-pushed the source-location branch 3 times, most recently from ba1e6b0 to a534129 Compare September 18, 2018 16:09
@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test

@johnno1962
Copy link
Contributor Author

johnno1962 commented Sep 18, 2018

@jrose-apple I think I may have pushed a commit after your Please smoke test

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

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

Thank you!

@rintaro rintaro merged commit eb450ee into swiftlang:master Sep 19, 2018
@johnno1962
Copy link
Contributor Author

johnno1962 commented Sep 19, 2018

Thanks all, we got there there in the end. Any thoughts on the rather eccentric #19347?

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.

4 participants