Conversation
263df49 to
877f497
Compare
75236a8 to
a10344c
Compare
| (peek_at(parser, following) == '.') || | ||
| (peek_at(parser, following) == '&' && peek_at(parser, following + 1) == '.') |
There was a problem hiding this comment.
Would it be better to use store peek_at(parser, following) into an intermediate variable?
| (peek_at(parser, following) == '&' && peek_at(parser, following + 1) == '&') || | ||
| (peek_at(parser, following) == '|' && peek_at(parser, following + 1) == '|') || | ||
| (peek_at(parser, following) == 'a' && peek_at(parser, following + 1) == 'n' && peek_at(parser, following + 2) == 'd' && !char_is_identifier(parser, following + 3, parser->end - (following + 3))) || | ||
| (peek_at(parser, following) == 'o' && peek_at(parser, following + 1) == 'r' && !char_is_identifier(parser, following + 2, parser->end - (following + 2))) |
There was a problem hiding this comment.
Same question here about all the peek_at(parser, following)
This makes it hard to do version checks against this value. The current version checks work because there are so few possible values at the moment. As an example, ruby#3337 introduces new syntax for ruby 3.5 and uses `PM_OPTIONS_VERSION_LATEST` as its version guard. Because what is considered the latest changes every year, it must later be changed to `parser->version == parser->version == PM_OPTIONS_VERSION_CRUBY_3_5 || parser->version == PM_OPTIONS_VERSION_LATEST`, with one extra version each year. With this change, the PR can instead write `parser->version >= PM_OPTIONS_VERSION_CRUBY_3_5` which is self-explanatory and works for future versions.
This makes it hard to do version checks against this value. The current version checks work because there are so few possible values at the moment. As an example, ruby#3337 introduces new syntax for ruby 3.5 and uses `PM_OPTIONS_VERSION_LATEST` as its version guard. Because what is considered the latest changes every year, it must later be changed to `parser->version == parser->version == PM_OPTIONS_VERSION_CRUBY_3_5 || parser->version == PM_OPTIONS_VERSION_LATEST`, with one extra version each year. With this change, the PR can instead write `parser->version >= PM_OPTIONS_VERSION_CRUBY_3_5` which is self-explanatory and works for future versions.
src/prism.c
Outdated
| (peek_at(parser, following) == '.') || | ||
| (peek_at(parser, following) == '&' && peek_at(parser, following + 1) == '.') | ||
| )) | ||
| (parser->version == PM_OPTIONS_VERSION_LATEST) && |
There was a problem hiding this comment.
I found this version check a bit strange since LATEST is a moving target and openend #3605 to talk about it.
There was a problem hiding this comment.
PR above was merged, this should now be this
| (parser->version == PM_OPTIONS_VERSION_LATEST) && | |
| (parser->version >= PM_OPTIONS_VERSION_CRUBY_3_5) && |
src/prism.c
Outdated
| (peek_at(parser, following) == '.') || | ||
| (peek_at(parser, following) == '&' && peek_at(parser, following + 1) == '.') | ||
| )) | ||
| (parser->version == PM_OPTIONS_VERSION_LATEST) && |
There was a problem hiding this comment.
PR above was merged, this should now be this
| (parser->version == PM_OPTIONS_VERSION_LATEST) && | |
| (parser->version >= PM_OPTIONS_VERSION_CRUBY_3_5) && |
src/prism.c
Outdated
| LEX(PM_TOKEN_AMPERSAND_DOT); | ||
| } | ||
|
|
||
| if (parser->version == PM_OPTIONS_VERSION_LATEST) { |
There was a problem hiding this comment.
| if (parser->version == PM_OPTIONS_VERSION_LATEST) { | |
| if (parser->version >= PM_OPTIONS_VERSION_CRUBY_3_5) { |
|
FYI Matz approved this feature a week ago in https://bugs.ruby-lang.org/issues/20925#note-11 |
a10344c to
0e67140
Compare
0e67140 to
3f58fa7
Compare
|
Hey @kddnewton, this change seems to turn methods called
|
|
Hm, no. I don't think that is intentional. Do you have an account on https://bugs.ruby-lang.org to report this? If not, I can do it for you. It will need to be backported and be fixed in parse.y as well. If you need to work around this now, you can add empty parens to your method like |
|
I don't have an account there, no, feel free to report yourself. Wrapping with parenthesis solves it, but it did look unintentional so I wanted to mention it 👍 |
|
I reported at https://bugs.ruby-lang.org/issues/21946, #3966 will fix this. It will probably be backported. |

Per https://bugs.ruby-lang.org/issues/20925