ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:120233] [Ruby master Bug#20952] A weird error message for []= with keyword arguments
@ 2024-12-13 19:47 zverok (Victor Shepelev) via ruby-core
  2024-12-13 20:01 ` [ruby-core:120234] " jeremyevans0 (Jeremy Evans) via ruby-core
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: zverok (Victor Shepelev) via ruby-core @ 2024-12-13 19:47 UTC (permalink / raw)
  To: ruby-core; +Cc: zverok (Victor Shepelev)

Issue #20952 has been reported by zverok (Victor Shepelev).

----------------------------------------
Bug #20952: A weird error message for []= with keyword arguments
https://bugs.ruby-lang.org/issues/20952

* Author: zverok (Victor Shepelev)
* Status: Open
* Backport: 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED
----------------------------------------
Trying to document the new deprecation of `#[]=` with keyword arguments, I wrote this sample code:

```ruby
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?..

```
$ ruby -v
ruby 3.4.0dev (2024-12-11T19:50:20Z master 34e68548d4) +PRISM [x86_64-linux]
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:120234] [Ruby master Bug#20952] A weird error message for []= with keyword arguments
  2024-12-13 19:47 [ruby-core:120233] [Ruby master Bug#20952] A weird error message for []= with keyword arguments zverok (Victor Shepelev) via ruby-core
@ 2024-12-13 20:01 ` jeremyevans0 (Jeremy Evans) via ruby-core
  2024-12-13 20:53 ` [ruby-core:120235] " jeremyevans0 (Jeremy Evans) via ruby-core
  2024-12-13 21:24 ` [ruby-core:120236] " eightbitraptor (Matt V-H) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2024-12-13 20:01 UTC (permalink / raw)
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #20952 has been updated by jeremyevans0 (Jeremy Evans).


This is a bug in prism.  The expected behavior is parse.y's behavior of raising a syntax error:

```
$ ruby34 -c -e "matrix[5, axis: :y] = 8"                  
Syntax OK

$ ruby34 --parser=parse.y -c -e "matrix[5, axis: :y] = 8"
-e:1: keyword arg given in index assignment
matrix[5, axis: :y] = 8
ruby34: compile error (SyntaxError)
```

----------------------------------------
Bug #20952: A weird error message for []= with keyword arguments
https://bugs.ruby-lang.org/issues/20952#change-110999

* Author: zverok (Victor Shepelev)
* Status: Open
* Backport: 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED
----------------------------------------
Trying to document the new deprecation of `#[]=` with keyword arguments, I wrote this sample code:

```ruby
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?..

```
$ ruby -v
ruby 3.4.0dev (2024-12-11T19:50:20Z master 34e68548d4) +PRISM [x86_64-linux]
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:120235] [Ruby master Bug#20952] A weird error message for []= with keyword arguments
  2024-12-13 19:47 [ruby-core:120233] [Ruby master Bug#20952] A weird error message for []= with keyword arguments zverok (Victor Shepelev) via ruby-core
  2024-12-13 20:01 ` [ruby-core:120234] " jeremyevans0 (Jeremy Evans) via ruby-core
@ 2024-12-13 20:53 ` jeremyevans0 (Jeremy Evans) via ruby-core
  2024-12-13 21:24 ` [ruby-core:120236] " eightbitraptor (Matt V-H) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2024-12-13 20:53 UTC (permalink / raw)
  To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)

Issue #20952 has been updated by jeremyevans0 (Jeremy Evans).


Same is true for block arguments:

```
$ ruby34 -c -e "matrix[5, &block] = 8"   
Syntax OK

$ ruby34 --parser=parse.y -c -e "matrix[5, &block] = 8"
-e:1: block arg given in index assignment
matrix[5, &block] = 8
ruby34: compile error (SyntaxError)
```

----------------------------------------
Bug #20952: A weird error message for []= with keyword arguments
https://bugs.ruby-lang.org/issues/20952#change-111000

* Author: zverok (Victor Shepelev)
* Status: Open
* Backport: 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED
----------------------------------------
Trying to document the new deprecation of `#[]=` with keyword arguments, I wrote this sample code:

```ruby
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?..

```
$ ruby -v
ruby 3.4.0dev (2024-12-11T19:50:20Z master 34e68548d4) +PRISM [x86_64-linux]
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:120236] [Ruby master Bug#20952] A weird error message for []= with keyword arguments
  2024-12-13 19:47 [ruby-core:120233] [Ruby master Bug#20952] A weird error message for []= with keyword arguments zverok (Victor Shepelev) via ruby-core
  2024-12-13 20:01 ` [ruby-core:120234] " jeremyevans0 (Jeremy Evans) via ruby-core
  2024-12-13 20:53 ` [ruby-core:120235] " jeremyevans0 (Jeremy Evans) via ruby-core
@ 2024-12-13 21:24 ` eightbitraptor (Matt V-H) via ruby-core
  2 siblings, 0 replies; 4+ messages in thread
From: eightbitraptor (Matt V-H) via ruby-core @ 2024-12-13 21:24 UTC (permalink / raw)
  To: ruby-core; +Cc: eightbitraptor (Matt V-H)

Issue #20952 has been updated by eightbitraptor (Matt V-H).

Status changed from Closed to Open

Re-Opening this in light of @jeremyevans0 comment about blocks

I merged the PR that addresses the kwargs issue at the same time as that comment was made.

----------------------------------------
Bug #20952: A weird error message for []= with keyword arguments
https://bugs.ruby-lang.org/issues/20952#change-111002

* Author: zverok (Victor Shepelev)
* Status: Open
* Backport: 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED
----------------------------------------
Trying to document the new deprecation of `#[]=` with keyword arguments, I wrote this sample code:

```ruby
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?..

```
$ ruby -v
ruby 3.4.0dev (2024-12-11T19:50:20Z master 34e68548d4) +PRISM [x86_64-linux]
```



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-13 21:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-13 19:47 [ruby-core:120233] [Ruby master Bug#20952] A weird error message for []= with keyword arguments zverok (Victor Shepelev) via ruby-core
2024-12-13 20:01 ` [ruby-core:120234] " jeremyevans0 (Jeremy Evans) via ruby-core
2024-12-13 20:53 ` [ruby-core:120235] " jeremyevans0 (Jeremy Evans) via ruby-core
2024-12-13 21:24 ` [ruby-core:120236] " eightbitraptor (Matt V-H) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).