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
Remove comma as enum member delimiter #7618
Changes from all commits
307b224
df027d0
6704bef
354c79a
8a41cfe
9f6fa91
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 |
---|---|---|
|
@@ -2060,14 +2060,15 @@ module Crystal | |
end | ||
|
||
# This is the case of an enum member | ||
if node.name[0].ascii_uppercase? && @token.type == :"," | ||
write "," | ||
# TODO: remove comma support after 0.28.0 | ||
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. Support for commas should stay regardless. 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. This is not the consensus from #7608, though no dead line is decided. It could be pushed further. 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. Having this TODO is certainly better than not, even if we later decided to keep this conversion indefinitely. But I don't think that's reasonable. We don't need to throw it out in the next version, but eventually it would just be useless dead code. |
||
if @token.type == :";" || (node.name[0].ascii_uppercase? && @token.type == :",") | ||
next_token | ||
@lexer.skip_space | ||
if @token.type == :COMMENT | ||
write_comment | ||
@exp_needs_indent = true | ||
else | ||
write ";" if @token.type == :CONST | ||
write " " | ||
@exp_needs_indent = @token.type == :NEWLINE | ||
end | ||
|
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.
I'm not sure what the usual policy for the formatter is, but might it be possible to tell it to chew up old code with commas and re-format it, rather than outright failing?
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.
Good idea! We've done it in the past. But for that the parser will still have to support commas, or at least the parser used in the formatter (could be toggled with a flag). I like that idea.
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.
That would be similar to an autocorrection feature for
check
, but implemented in the formatter.I don't think it's urgent to completely abolish commas right away, so formatting them to semicolons seems like a good idea 👍