Bug #20952
closedA weird error message for []= with keyword arguments
Description
Trying to document the new deprecation of #[]= with keyword arguments, I wrote this sample code:
class MyMatrix
# ...some implementation
def []=(*args, **kwargs)
p(args:, kwargs:)
# ...some implementation
end
end
matrix = MyMatrix.new
matrix[5, axis: :y] = 8
This fails as expected, but the error message is totally unexpected for me:
ruby3_4.rb:11:in '<main>': undefined method '[]=' for an instance of Integer (NoMethodError)
matrix[5, axis: :y] = 8
^^^^^^^^^^^^^^^
Am I missing some interpretation peculiarity here?..
Updated by jeremyevans0 (Jeremy Evans) over 1 year ago
This is a bug in prism. The expected behavior is parse.y's behavior of raising a syntax error:
Updated by jeremyevans0 (Jeremy Evans) over 1 year ago
Updated by eightbitraptor (Matt V-H) over 1 year ago
- Status changed from Open to Closed
Applied in changeset git|e1946657205fb14583dd3020d60c5236a11fdd9b.
[PRISM] using []= to set kwargs is a syntax error
Fixes [Bug #20952]
Updated by eightbitraptor (Matt V-H) over 1 year ago
- Status changed from Closed to Open
Re-Opening this in light of @jeremyevans0 (Jeremy Evans) comment about blocks
I merged the PR that addresses the kwargs issue at the same time as that comment was made.
Updated by eightbitraptor (Matt V-H) over 1 year ago
- Status changed from Open to Closed
Applied in changeset git|b37777c36f6cb27d55f4fe44a95b3c970fbf9848.
[PRISM] Blocks are also a syntax error in array assignment
Actually close [Bug #20952]