Follow fix for method call with in bug#3666
Conversation
| pm_call_node_t *cast = (pm_call_node_t *) node; | ||
| if (cast->arguments != NULL && cast->opening_loc.start == NULL && parser->current.type == PM_TOKEN_KEYWORD_IN) { | ||
| return node; | ||
| } |
There was a problem hiding this comment.
I need @kddnewton's opinion here, but I feel like testing for a specific token isn't the right fix and that we should be using binding power instead (but this is just a gut feeling). Is in the only keyword that has a problem?
There was a problem hiding this comment.
Is
inthe only keyword that has a problem?
Looks like in, =>, ., &. and all binary operators except + - ** & * are wrongly accepted after A.print message: but not after a.print message:
There was a problem hiding this comment.
And ternary operator A.print message: ? 1 : 2
There was a problem hiding this comment.
I agree with @tenderlove that this is not the correct fix. The code that is supposed to handle this is here:
Lines 22253 to 22261 in ce4abe1
But parse_expression_prefix returns PM_CONSTANT_READ_NODE. So I feel like the fix would be to modify parse_expression_prefix so that it parses further instead of just one node deep. Or this check is also needed at some other place.
But I did not manage to actually fix it myself last I looked into this.
This PR is a followup to ruby#3558 and fixes the following cases, which should throw a syntax error but were not: ```ruby A.print message: in 'BAR' A.print message: in 'BAR' ``` To fix this we check for methods calls with arguments and no parens that then call `in`. Note I had claude write this because I wasn't sure where the problem was but then edited it to remove extra unnecessary code the robot wrote.
efdbb28 to
ed96da8
Compare
|
I made some changes and don't think this is done yet. I added some new tests so we have more coverage while figuring this out. The @tompng do you have a script you're running that we can use to figure out which others are still not working correctly? Thanks! |
|
For this case, I don't have a script. I just listed up by glazing at all symbol keys in my keyboard and tried |
This PR is a followup to #3558 and fixes the following cases, which should throw a syntax error but were not:
To fix this we check for methods calls with arguments and no parens that then call
in.Note I had claude write this because I wasn't sure where the problem was but then edited it to remove extra unnecessary code the robot wrote.
cc/ @tenderlove @kddnewton