From 23beceedb76a47b3f4497809eefb7338690df191 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Tue, 2 Jan 2024 11:18:29 -0500 Subject: [ruby/prism] IndexTargetNode should always have ATTRIBUTE_WRITE Because this is a user-facing change, we also need to deal with the fact that CRuby 3.3.0 was just released. In order to support workflows that want to parse exactly as CRuby parses in a specific version, this PR introduces a new option to the options struct that is "version". This allows you to specify that you want "3.3.0" parsing. I'm not sure if this is the correct solution. Another solution is to just fork and keep around the old branch for security patches. Or we could keep around a copy of the source files within this repository as another directory and only update when necessary. There are a lot of potential solutions here. Because this change is so small and the check for it is so minimal, I've decided to go with this enum. If this ends up entirely cluttering the codebase with version checks, we'll come up with another solution. But for now this works, so we're going to go in this direction for a bit until we determine it's no longer working. https://github.com/ruby/prism/commit/d8c7e6bd10 --- test/prism/snapshots/arrays.txt | 8 ++++---- test/prism/snapshots/unparser/corpus/literal/assignment.txt | 8 ++++---- test/prism/snapshots/whitequark/masgn_attr.txt | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/prism/snapshots/arrays.txt b/test/prism/snapshots/arrays.txt index 93f5c8fbc1..40d4cbed4f 100644 --- a/test/prism/snapshots/arrays.txt +++ b/test/prism/snapshots/arrays.txt @@ -430,7 +430,7 @@ ├── @ MultiWriteNode (location: (41,0)-(41,21)) │ ├── lefts: (length: 2) │ │ ├── @ IndexTargetNode (location: (41,0)-(41,6)) - │ │ │ ├── flags: ∅ + │ │ │ ├── flags: attribute_write │ │ │ ├── receiver: │ │ │ │ @ CallNode (location: (41,0)-(41,3)) │ │ │ │ ├── flags: variable_call @@ -452,7 +452,7 @@ │ │ │ ├── closing_loc: (41,5)-(41,6) = "]" │ │ │ └── block: ∅ │ │ └── @ IndexTargetNode (location: (41,8)-(41,14)) - │ │ ├── flags: ∅ + │ │ ├── flags: attribute_write │ │ ├── receiver: │ │ │ @ CallNode (location: (41,8)-(41,11)) │ │ │ ├── flags: variable_call @@ -2166,7 +2166,7 @@ │ │ │ ├── operator_loc: (140,17)-(140,19) = "=>" │ │ │ ├── reference: │ │ │ │ @ IndexTargetNode (location: (140,20)-(140,24)) - │ │ │ │ ├── flags: ∅ + │ │ │ │ ├── flags: attribute_write │ │ │ │ ├── receiver: │ │ │ │ │ @ CallNode (location: (140,20)-(140,21)) │ │ │ │ │ ├── flags: variable_call @@ -2229,7 +2229,7 @@ │ │ ├── operator_loc: (142,17)-(142,19) = "=>" │ │ ├── reference: │ │ │ @ IndexTargetNode (location: (142,20)-(142,27)) - │ │ │ ├── flags: ∅ + │ │ │ ├── flags: attribute_write │ │ │ ├── receiver: │ │ │ │ @ CallNode (location: (142,20)-(142,21)) │ │ │ │ ├── flags: variable_call diff --git a/test/prism/snapshots/unparser/corpus/literal/assignment.txt b/test/prism/snapshots/unparser/corpus/literal/assignment.txt index 18edafe415..4cb19d2867 100644 --- a/test/prism/snapshots/unparser/corpus/literal/assignment.txt +++ b/test/prism/snapshots/unparser/corpus/literal/assignment.txt @@ -319,7 +319,7 @@ ├── @ MultiWriteNode (location: (15,0)-(15,24)) │ ├── lefts: (length: 2) │ │ ├── @ IndexTargetNode (location: (15,1)-(15,8)) - │ │ │ ├── flags: ∅ + │ │ │ ├── flags: attribute_write │ │ │ ├── receiver: │ │ │ │ @ LocalVariableReadNode (location: (15,1)-(15,2)) │ │ │ │ ├── name: :a @@ -338,7 +338,7 @@ │ │ │ ├── closing_loc: (15,7)-(15,8) = "]" │ │ │ └── block: ∅ │ │ └── @ IndexTargetNode (location: (15,10)-(15,14)) - │ │ ├── flags: ∅ + │ │ ├── flags: attribute_write │ │ ├── receiver: │ │ │ @ LocalVariableReadNode (location: (15,10)-(15,11)) │ │ │ ├── name: :a @@ -370,7 +370,7 @@ ├── @ MultiWriteNode (location: (16,0)-(16,21)) │ ├── lefts: (length: 2) │ │ ├── @ IndexTargetNode (location: (16,1)-(16,5)) - │ │ │ ├── flags: ∅ + │ │ │ ├── flags: attribute_write │ │ │ ├── receiver: │ │ │ │ @ LocalVariableReadNode (location: (16,1)-(16,2)) │ │ │ │ ├── name: :a @@ -385,7 +385,7 @@ │ │ │ ├── closing_loc: (16,4)-(16,5) = "]" │ │ │ └── block: ∅ │ │ └── @ IndexTargetNode (location: (16,7)-(16,11)) - │ │ ├── flags: ∅ + │ │ ├── flags: attribute_write │ │ ├── receiver: │ │ │ @ LocalVariableReadNode (location: (16,7)-(16,8)) │ │ │ ├── name: :a diff --git a/test/prism/snapshots/whitequark/masgn_attr.txt b/test/prism/snapshots/whitequark/masgn_attr.txt index d87d7a6cb1..2a4dc38b7c 100644 --- a/test/prism/snapshots/whitequark/masgn_attr.txt +++ b/test/prism/snapshots/whitequark/masgn_attr.txt @@ -34,7 +34,7 @@ │ │ │ ├── name: :a= │ │ │ └── message_loc: (3,5)-(3,6) = "a" │ │ └── @ IndexTargetNode (location: (3,8)-(3,18)) - │ │ ├── flags: ∅ + │ │ ├── flags: attribute_write │ │ ├── receiver: │ │ │ @ SelfNode (location: (3,8)-(3,12)) │ │ ├── opening_loc: (3,12)-(3,13) = "[" -- cgit v1.2.3