-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
[RFC 0118] Extra semicolon as a warning instead of an syntax error #118
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
feature: optional-final-semicolon | ||
start-date: 2021-12-03 | ||
author: Lucas Eduardo Wendt | ||
co-authors: (find a buddy later to help out with the RFC) | ||
shepherd-team: (names, to be nominated and accepted by RFC steering committee) | ||
shepherd-leader: (name to be appointed by RFC steering committee) | ||
related-issues: (will contain links to implementation PRs) | ||
--- | ||
|
||
# Summary | ||
[summary]: #summary | ||
|
||
Make it acceptable a semicolon at the end of a Nix expression raising a warning instead of a syntax error. | ||
|
||
# Motivation | ||
[motivation]: #motivation | ||
|
||
Faster iterations. | ||
|
||
Some people use full keyboard editors and hack around with their configurations, sometimes you move code from the final | ||
part to a let expression or the reverse to test something or debug some faulty part then forgot a semicolon on the | ||
final of the last line, the code fails with a syntax error then you reopen the editor just to remove the semicolon to | ||
make the parser happy, then you forgot the semicolon when you put the thing back to a let expression. This should be | ||
a recoverable syntax issue just raising a warning to remove that semicolon when all is over. | ||
|
||
This would make iterations a little faster and bring a bit less friction, and give a better clue about what is going on in this case. | ||
|
||
# Detailed design | ||
[design]: #detailed-design | ||
|
||
Allow an optional semicolon at the end of an expression raising a warning if it's provided. | ||
|
||
# Examples and Interactions | ||
[examples-and-interactions]: #examples-and-interactions | ||
|
||
=> 2+2 | ||
4 | ||
=> 2+2; | ||
warning: extra semicolon at the end of the expression | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For files, it should also show which file is having the extra semicolon. |
||
4 | ||
|
||
The second example raises a syntax error on, for example, Nix 2.4 | ||
|
||
``` | ||
nix-repl> 2+2 | ||
4 | ||
|
||
nix-repl> 2+2; | ||
error: syntax error, unexpected ';', expecting end of file | ||
|
||
at «string»:1:4: | ||
|
||
1| 2+2; | ||
| ^ | ||
2| | ||
``` | ||
|
||
# Drawbacks | ||
[drawbacks]: #drawbacks | ||
|
||
- Temporary unhandled edge case for secondary nix parsers like [rnix-parser](https://github.com/nix-community/rnix-parser) that by consequency affects [rnix-lsp](https://github.com/nix-community/rnix-lsp) | ||
|
||
# Alternatives | ||
[alternatives]: #alternatives | ||
|
||
There are no alternatives so far. | ||
|
||
The impact of not doing this is not critic. | ||
Comment on lines
+67
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One alternative is changing the error from:
to something like:
That said, allowing people to write |
||
|
||
# Unresolved questions | ||
[unresolved]: #unresolved-questions | ||
|
||
What parts of the design are still TBD or unknowns? | ||
|
||
# Future work | ||
[future]: #future-work | ||
|
||
What future work, if any, would be implied or impacted by this feature | ||
without being directly part of the work? |
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.
This is not a detailed design.
I would expect to get a good idea of how this will be implemented technically.
Note that I tried adding an optional semicolon to the parser a few years ago, but it was rejected because my implementation was naïve (just have a giant lookahead essentially). So I’d like to see a technical design here that is feasible.