Skip to content

Conversation

@thomasmarshall
Copy link

This PR enables the dynamic assignment check for multi targets. The comments in the regression test said Sorbet doesn't do the dynamic constant workaround for multi-target assignments—that may have been the case when the original translator was added, but doesn't appear to be so now.

The following code was crashing:

def foo
  A, B = 1, 2
end

Enabling the dynamic assignment check for the multi target results in this being desugared in the same way as the original parser, and therefore no longer crashes:

Prism:

class <emptyTree><<C <root>>> < (::<todo sym>)
  def foo<<todo method>>(&<blk>)
    begin
      <assignTemp>$2 = [1, 2]
      <assignTemp>$3 = ::<Magic>.<expand-splat>(<assignTemp>$2, 2, 0)
      <dynamic-const-assign> = <assignTemp>$3.[](0)
      <dynamic-const-assign> = <assignTemp>$3.[](1)
      <assignTemp>$2
    end
  end
end

Original:

class <emptyTree><<C <root>>> < (::<todo sym>)
  def foo<<todo method>>(&<blk>)
    begin
      <assignTemp>$2 = [1, 2]
      <assignTemp>$3 = ::<Magic>.<expand-splat>(<assignTemp>$2, 2, 0)
      <dynamic-const-assign> = <assignTemp>$3.[](0)
      <dynamic-const-assign> = <assignTemp>$3.[](1)
      <assignTemp>$2
    end
  end
end

The error messages are also identical:

test.rb:2: dynamic constant assignment https://srb.help/2001
     2 |  A, B = 1, 2
          ^

test.rb:2: dynamic constant assignment https://srb.help/2001
     2 |  A, B = 1, 2
             ^
Errors: 2

@amomchilov amomchilov force-pushed the desugar-remaining branch 2 times, most recently from d96acf3 to 7f35d5d Compare December 19, 2025 19:25
@thomasmarshall thomasmarshall force-pushed the check-dynamic-multi-target-assignment branch from 7960e0a to cec6fd2 Compare January 7, 2026 12:15
@thomasmarshall thomasmarshall force-pushed the check-dynamic-multi-target-assignment branch from cec6fd2 to a61b22f Compare January 7, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants