Actions
Bug #10653
closeddo-end block in ternary operator is syntax error
Bug #10653:
do-end block in ternary operator is syntax error
Description
- For example
- Result by 2.1.5
- Result by 2.2.0
Actions
Added by yancya (Shinta Koyanagi) over 11 years ago. Updated over 10 years ago.
Description
Applied in changeset r51617.
parse.y: fix block after conditional
After backporting r50409 and r51617, TestSyntax#test_block_after_cond failed.
r51616 should be backported too?
r50409, r51616, r51617 and r51624 were backported into ruby_2_2 branch at r52046.
With r50409 a minor incompatibility is introduced ({ %w"key": 0 } cause SyntaxError).
I'm not confident the incompatibility is essential part of this fixes, but the accurate surgery is required to eliminate the incompatibility. I gave up.
I was implementing this in my Ruby parser and I found a much simpler solution than what you've implemented here: https://github.com/whitequark/parser/commit/113442eff1f9c6f7e7205ec0dac8cb858b3b0fc7
In short, instead of explicitly enumerating all contexts where a label is valid, I only disallow quoted label at EXPR_VALUE using an additional flag. It works just as well. It also would not exhibit the bug with %w during backport.
Might I suggest a simplification to parse.y?
Currently it's a bit flag in parse.y too.