Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected write target for multi write node #2687

Closed
Morriar opened this issue Apr 8, 2024 · 3 comments
Closed

Unexpected write target for multi write node #2687

Morriar opened this issue Apr 8, 2024 · 3 comments
Labels

Comments

@Morriar
Copy link
Contributor

Morriar commented Apr 8, 2024

This snippet:

(
  foo,
  bar
) = 42

Returns a Prism::ParseError, unexpected write target error with Prism (though the AST seems to be parsed properly):

#<Prism::ParseResult:0x0000000104abb1e8
 @comments=[],
 @data_loc=nil,
 @errors=
  [#<Prism::ParseError @message="unexpected write target" @location=#<Prism::Location @start_offset=2 @length=8 start_line=2>>],
 @magic_comments=[],
 @source=#<Prism::Source:0x00000001018e15c8 @offsets=[0, 2, 7, 11], @source="(\nfoo,\nbar\n)=42", @start_line=1>,
 @value=
  @ ProgramNode (location: (1,0)-(4,4))
  ├── locals: [:foo, :bar]
  └── statements:
      @ StatementsNode (location: (1,0)-(4,4))
      └── body: (length: 1)
          └── @ MultiWriteNode (location: (1,0)-(4,4))
              ├── lefts: (length: 2)
              │   ├── @ LocalVariableTargetNode (location: (2,0)-(2,3))
              │   │   ├── name: :foo
              │   │   └── depth: 0
              │   └── @ LocalVariableTargetNode (location: (3,0)-(3,3))
              │       ├── name: :bar
              │       └── depth: 0
              ├── rest: ∅
              ├── rights: (length: 0)
              ├── lparen_loc: (1,0)-(1,1) = "("
              ├── rparen_loc: (4,0)-(4,1) = ")"
              ├── operator_loc: (4,1)-(4,2) = "="
              └── value:
                  @ IntegerNode (location: (4,2)-(4,4))
                  └── flags: decimal,
 @warnings=[]>

The same code seems to execute normally with Ruby:

$ ruby snippet.rb
42

@kddnewton
Copy link
Collaborator

I can't seem to reproduce this. Is this in 0.25.0?

@kddnewton
Copy link
Collaborator

I think this is what you ran: Prism.parse("(\nfoo,\nbar\n)=42"). It does not appear to be broken on main. I'll close as fixed.

@Morriar
Copy link
Contributor Author

Morriar commented Apr 9, 2024

Indeed it's not happening on 0.25, my bad 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants