ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:114997] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid?
@ 2023-10-11  5:40 tompng (tomoya ishida) via ruby-core
  2023-10-11  5:59 ` [ruby-core:114998] " mame (Yusuke Endoh) via ruby-core
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: tompng (tomoya ishida) via ruby-core @ 2023-10-11  5:40 UTC (permalink / raw
  To: ruby-core; +Cc: tompng (tomoya ishida)

Issue #19918 has been reported by tompng (tomoya ishida).

----------------------------------------
Bug #19918: Should `a[&b]=c` be syntax valid?
https://bugs.ruby-lang.org/issues/19918

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-10-11T04:46:58Z master 40ab7b8c24) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
These codes are syntax valid now. Prism parses it as syntax error.

~~~ruby
a[&b]=c
a[&b]+=c
a[&b]&&=c
a[&b]||=c
~~~

Is this syntax intentional or should be error?

Issue of Prism
https://github.com/ruby/prism/issues/1636

It's added in test_parse.rb
https://github.com/ruby/ruby/blob/40ab7b8c244de20007cb45846f41de3a01f7ea0c/test/ruby/test_parse.rb#L502




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:114998] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid?
  2023-10-11  5:40 [ruby-core:114997] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid? tompng (tomoya ishida) via ruby-core
@ 2023-10-11  5:59 ` mame (Yusuke Endoh) via ruby-core
  2023-10-11  6:24 ` [ruby-core:114999] " baweaver (Brandon Weaver) via ruby-core
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2023-10-11  5:59 UTC (permalink / raw
  To: ruby-core; +Cc: mame (Yusuke Endoh)

Issue #19918 has been updated by mame (Yusuke Endoh).


Assuming this is intentionally valid, I wonder if `a[&b] = c` should evaluate `b` before `c`.

----------------------------------------
Bug #19918: Should `a[&b]=c` be syntax valid?
https://bugs.ruby-lang.org/issues/19918#change-104866

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-10-11T04:46:58Z master 40ab7b8c24) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
These codes are syntax valid now. Prism parses it as syntax error.

~~~ruby
a[&b]=c
a[&b]+=c
a[&b]&&=c
a[&b]||=c
~~~

Is this syntax intentional or should be error?

Issue of Prism
https://github.com/ruby/prism/issues/1636

It's added in test_parse.rb
https://github.com/ruby/ruby/blob/40ab7b8c244de20007cb45846f41de3a01f7ea0c/test/ruby/test_parse.rb#L502




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:114999] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid?
  2023-10-11  5:40 [ruby-core:114997] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid? tompng (tomoya ishida) via ruby-core
  2023-10-11  5:59 ` [ruby-core:114998] " mame (Yusuke Endoh) via ruby-core
@ 2023-10-11  6:24 ` baweaver (Brandon Weaver) via ruby-core
  2023-10-11  8:50 ` [ruby-core:115001] " Eregon (Benoit Daloze) via ruby-core
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: baweaver (Brandon Weaver) via ruby-core @ 2023-10-11  6:24 UTC (permalink / raw
  To: ruby-core; +Cc: baweaver (Brandon Weaver)

Issue #19918 has been updated by baweaver (Brandon Weaver).


Is it bad that my first consideration is how this might be abused to do bad things for code golfing reasons? I blame mame.

----------------------------------------
Bug #19918: Should `a[&b]=c` be syntax valid?
https://bugs.ruby-lang.org/issues/19918#change-104867

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-10-11T04:46:58Z master 40ab7b8c24) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
These codes are syntax valid now. Prism parses it as syntax error.

~~~ruby
a[&b]=c
a[&b]+=c
a[&b]&&=c
a[&b]||=c
~~~

Is this syntax intentional or should be error?

Issue of Prism
https://github.com/ruby/prism/issues/1636

It's added in test_parse.rb
https://github.com/ruby/ruby/blob/40ab7b8c244de20007cb45846f41de3a01f7ea0c/test/ruby/test_parse.rb#L502




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:115001] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid?
  2023-10-11  5:40 [ruby-core:114997] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid? tompng (tomoya ishida) via ruby-core
  2023-10-11  5:59 ` [ruby-core:114998] " mame (Yusuke Endoh) via ruby-core
  2023-10-11  6:24 ` [ruby-core:114999] " baweaver (Brandon Weaver) via ruby-core
@ 2023-10-11  8:50 ` Eregon (Benoit Daloze) via ruby-core
  2023-10-11 10:39 ` [ruby-core:115005] " nobu (Nobuyoshi Nakada) via ruby-core
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2023-10-11  8:50 UTC (permalink / raw
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #19918 has been updated by Eregon (Benoit Daloze).


mame (Yusuke Endoh) wrote in #note-1:
> Assuming this is intentionally valid, I wonder if `a[&b] = c` should evaluate `b` before `c`.

That's the kind of complications which I think illustrates the Ruby syntax shouldn't support such edge cases.
It does not seem nearly useful or used enough to warrant those complications.
Literally I have never seen any code using `[]=` with a block.
If a block is useful the method should not be named with `[]=` but something clearer so it's easy to pass a block without such contortions.

----------------------------------------
Bug #19918: Should `a[&b]=c` be syntax valid?
https://bugs.ruby-lang.org/issues/19918#change-104869

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-10-11T04:46:58Z master 40ab7b8c24) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
These codes are syntax valid now. Prism parses it as syntax error.

~~~ruby
a[&b]=c
a[&b]+=c
a[&b]&&=c
a[&b]||=c
~~~

Is this syntax intentional or should be error?

Issue of Prism
https://github.com/ruby/prism/issues/1636

It's added in test_parse.rb
https://github.com/ruby/ruby/blob/40ab7b8c244de20007cb45846f41de3a01f7ea0c/test/ruby/test_parse.rb#L502




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:115005] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid?
  2023-10-11  5:40 [ruby-core:114997] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid? tompng (tomoya ishida) via ruby-core
                   ` (2 preceding siblings ...)
  2023-10-11  8:50 ` [ruby-core:115001] " Eregon (Benoit Daloze) via ruby-core
@ 2023-10-11 10:39 ` nobu (Nobuyoshi Nakada) via ruby-core
  2024-01-19  7:53 ` [ruby-core:116314] " mame (Yusuke Endoh) via ruby-core
  2024-01-19  9:01 ` [ruby-core:116319] " nobu (Nobuyoshi Nakada) via ruby-core
  5 siblings, 0 replies; 7+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2023-10-11 10:39 UTC (permalink / raw
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #19918 has been updated by nobu (Nobuyoshi Nakada).


Whether or not that is useful, it is at least intentional as there are some tests for them.

----------------------------------------
Bug #19918: Should `a[&b]=c` be syntax valid?
https://bugs.ruby-lang.org/issues/19918#change-104872

* Author: tompng (tomoya ishida)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0dev (2023-10-11T04:46:58Z master 40ab7b8c24) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
These codes are syntax valid now. Prism parses it as syntax error.

~~~ruby
a[&b]=c
a[&b]+=c
a[&b]&&=c
a[&b]||=c
~~~

Is this syntax intentional or should be error?

Issue of Prism
https://github.com/ruby/prism/issues/1636

It's added in test_parse.rb
https://github.com/ruby/ruby/blob/40ab7b8c244de20007cb45846f41de3a01f7ea0c/test/ruby/test_parse.rb#L502




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:116314] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid?
  2023-10-11  5:40 [ruby-core:114997] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid? tompng (tomoya ishida) via ruby-core
                   ` (3 preceding siblings ...)
  2023-10-11 10:39 ` [ruby-core:115005] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2024-01-19  7:53 ` mame (Yusuke Endoh) via ruby-core
  2024-01-19  9:01 ` [ruby-core:116319] " nobu (Nobuyoshi Nakada) via ruby-core
  5 siblings, 0 replies; 7+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2024-01-19  7:53 UTC (permalink / raw
  To: ruby-core; +Cc: mame (Yusuke Endoh)

Issue #19918 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to yui-knk (Kaneko Yuichiro)

Discussed at the dev meeting. @matz wanted to allow `a[&b]` and forbid `a[&b] = c` if the implementation is not overly cumbersome.

@yui-knk What do you think?

Note: During the meeting, we found that the compilation of `a[&b], c[&d] = e, f` is apparently buggy. If it is difficult to prohibit the grammar, we need to fix this bug.

----------------------------------------
Bug #19918: Should `a[&b]=c` be syntax valid?
https://bugs.ruby-lang.org/issues/19918#change-106338

* Author: tompng (tomoya ishida)
* Status: Assigned
* Priority: Normal
* Assignee: yui-knk (Kaneko Yuichiro)
* ruby -v: ruby 3.3.0dev (2023-10-11T04:46:58Z master 40ab7b8c24) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
These codes are syntax valid now. Prism parses it as syntax error.

~~~ruby
a[&b]=c
a[&b]+=c
a[&b]&&=c
a[&b]||=c
~~~

Is this syntax intentional or should be error?

Issue of Prism
https://github.com/ruby/prism/issues/1636

It's added in test_parse.rb
https://github.com/ruby/ruby/blob/40ab7b8c244de20007cb45846f41de3a01f7ea0c/test/ruby/test_parse.rb#L502




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:116319] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid?
  2023-10-11  5:40 [ruby-core:114997] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid? tompng (tomoya ishida) via ruby-core
                   ` (4 preceding siblings ...)
  2024-01-19  7:53 ` [ruby-core:116314] " mame (Yusuke Endoh) via ruby-core
@ 2024-01-19  9:01 ` nobu (Nobuyoshi Nakada) via ruby-core
  5 siblings, 0 replies; 7+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2024-01-19  9:01 UTC (permalink / raw
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #19918 has been updated by nobu (Nobuyoshi Nakada).


https://github.com/nobu/ruby/tree/ary_set-block

----------------------------------------
Bug #19918: Should `a[&b]=c` be syntax valid?
https://bugs.ruby-lang.org/issues/19918#change-106345

* Author: tompng (tomoya ishida)
* Status: Assigned
* Priority: Normal
* Assignee: yui-knk (Kaneko Yuichiro)
* ruby -v: ruby 3.3.0dev (2023-10-11T04:46:58Z master 40ab7b8c24) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
These codes are syntax valid now. Prism parses it as syntax error.

~~~ruby
a[&b]=c
a[&b]+=c
a[&b]&&=c
a[&b]||=c
~~~

Is this syntax intentional or should be error?

Issue of Prism
https://github.com/ruby/prism/issues/1636

It's added in test_parse.rb
https://github.com/ruby/ruby/blob/40ab7b8c244de20007cb45846f41de3a01f7ea0c/test/ruby/test_parse.rb#L502




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

end of thread, other threads:[~2024-01-19  9:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-11  5:40 [ruby-core:114997] [Ruby master Bug#19918] Should `a[&b]=c` be syntax valid? tompng (tomoya ishida) via ruby-core
2023-10-11  5:59 ` [ruby-core:114998] " mame (Yusuke Endoh) via ruby-core
2023-10-11  6:24 ` [ruby-core:114999] " baweaver (Brandon Weaver) via ruby-core
2023-10-11  8:50 ` [ruby-core:115001] " Eregon (Benoit Daloze) via ruby-core
2023-10-11 10:39 ` [ruby-core:115005] " nobu (Nobuyoshi Nakada) via ruby-core
2024-01-19  7:53 ` [ruby-core:116314] " mame (Yusuke Endoh) via ruby-core
2024-01-19  9:01 ` [ruby-core:116319] " nobu (Nobuyoshi Nakada) 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 read-only IMAP folder(s) and NNTP newsgroup(s).