Skip to content

Rightward assignment inside "case ... when" produces invalid syntax #235

Closed
@hpello

Description

@hpello

Hey there!

I noticed the following behaviour, when using rightward assignment => inside a case ... when:

puts SyntaxTree.format <<~RUBY
  case [0]
  when 0
    { a: 0 } => { a: }
    puts a
  end
RUBY

produces:

[0] =>
  when 0
    case { a: 0 }
    a:
    end
    puts a

It seems like the rightward assignment is moved to the top... producing an invalid ruby syntax.
Do you know where this may come from?

Regards,

Activity

kddnewton

kddnewton commented on Dec 28, 2022

@kddnewton
Member

Ahh this is a problem with the parser. Just found the fix, thanks!

added a commit that references this issue on Dec 28, 2022
added a commit that references this issue on Dec 28, 2022

Merge pull request #236 from ruby-syntax-tree/fixes

31e580b
hpello

hpello commented on Dec 28, 2022

@hpello
Author

Works like a charm! Thanks 👏🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @kddnewton@hpello

      Issue actions

        Rightward assignment inside "case ... when" produces invalid syntax · Issue #235 · ruby-syntax-tree/syntax_tree