-
Notifications
You must be signed in to change notification settings - Fork 846
Fix lexing hash directives and raise errors (2nd attempt) - several cases #9906
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
Conversation
a9e548d to
5a882a8
Compare
|
@abelbraaksma for the sake of incrementality, how would you feel if we just reviewed and aimed to merge what is here already? |
|
@cartermp, that's probably a good idea. Let me merge and fix over the weekend so that this can be reviewed. |
cartermp
left a comment
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! I think this looks good.
KevinRansom
left a comment
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.
Looks, good, but what do you want to do with the todo?
| // TODO unreachable error above, I think? - brianmcn | ||
| let s = lexeme lexbuf | ||
| warning(Error((0, sprintf "%s should only be set once in an F# source file." s), lexbuf.LexemeRange)) | ||
| // TODO: where should this go? (abelb) |
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.
@abelbraaksma --- is this intended?
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.
@KevinRansom I think I meant that all errors go in a resource file (iirc) and this line as it is is not localizable. When I wrote that I didn't know where to place the localizable string.
The other thing here is probably the error/warning number, which here is 0. I don't know what number to choose. It's been like that for a while, so I guess I could also fix it in a future pr. How are these numbers assigned? Just choose a free one?
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.
Side effect of current code is, I guess, that you won't be able to disable this warning as it is written...
|
I will merge this since the comment is benign.
Yep, you can create a new one in FSComp.txt and when you run |
|
Thanks for the contribution! Feel free to follow up as you see fit. |
|
This one caused a build break on integration |
|
Changing { let n = Array.IndexOf(lexbuf.Lexeme, '#') to { let n = (lexeme lexbuf).IndexOf('#') worked for me I'll submit a PR |
Fixes #3487.
Fixes #9787.
[continued from #9779, because somehow Github didn't understand the diff-view anymore, showing 100s unrelated non-existing changes. Close/recreate PR with exactly the same changes seemed to fix this]
This resurrects the work done in #5498 by @misonijnik . In short, it's an attempt to make sure that:
Some tests were failing on the original PR, I merged it with latest master and marked this WIP, as I want to see what those errors were, though I don't expect to work long on it, the change is pretty benign ;).
List of fixes (will be updated if necessary)
Fix wrong hash-token parsing (partially done)
#is now only recognized and leading to tokens if it is valid. This should be updated to include invalid items and the proper error and range for the lang service.Allow a type to start with the letters "if"
Previously

Implemented:

Fix wrong error for use of

#indent(text mentions '#light', instead of '#indent') (FS0000 warning (not assigned) for #light or #indent being misplaced #9787):Implemented, whole token shown:

Fix wrong error for use of

#light(FS0000 warning (not assigned) for #light or #indent being misplaced #9787):Implemented:

Fix wrong error when using wrong argument with

#light:Improve

#lightwhen token is wrong:After @misonijnik's change (error and range still to improve):

Fix wrong error with wrong token with

#if:After @misonijnik's change (error and range still to improve):

This fsharpqa test explicitly tests for leniency with hash-types starting with
#light:Conformance\TypesAndTypeConstraints\TypeParameterDefinitions (HashConstraint02.fs).Current situation

New situation

Fix wrong parsing of
lightwhen used as hash-constraint:Current situation

Generally: when
#is followed by an unrecognized token, I would expect an error that says that the token is not recognized.TODO: