Fix incompatibility AST for regexp match in Prism::Translation::Parser
#2548
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the following incompatibility AST for regexp match between Parser gem and Prism:
Parser gem
Returns an
match_with_lvasgn
node:Prism (
Prism::Translation::Parser
)Before
Returns an
send
node:After
Returns an
match_with_lvasgn
node:Background
Found due to incompatibility with RuboCop's
Performance/EndWith
,Performance/StringInclude, and
Performance/StartWith` cops.Note
This is the incompatibility when the receiver is a regular expression literal and
=~
is used. Based on the node name:match_with_lvasgn
, it appears that Prism's AST becomes more accurate in cases likevisit_match_write_node
only.However, as shown in the background, the current behavior of Parser gem is not like this. Considering compatibility with the published AST of Parser gem, the AST incompatibility will be addressed.
This lvar-injecting feature appears to have not been supported by Parser gem for a long time: whitequark/parser#69 (comment)
There seems to be no indication that it will be supported.
This PR prioritizes AST compatibility between the Parser gem and Prism. However, it is unclear whether this is the best approach.