* [ruby-core:123259] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error
2025-09-13 14:14 [ruby-core:123241] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error kddnewton (Kevin Newton) via ruby-core
@ 2025-09-16 10:15 ` Earlopain (Earlopain _) via ruby-core
2025-09-17 16:45 ` [ruby-core:123283] " kddnewton (Kevin Newton) via ruby-core
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2025-09-16 10:15 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #21572 has been updated by Earlopain (Earlopain _).
Thanks for opening this.
It seems just like a normal though, no? I understand that this doesn't deviate from what parse.y does but it is a syntax error and right now consumers of prism simply accept such code. I guess there are tests in ruby/ruby that very specifically assert against this somehow? Other than that, is seems like an implementation detail.
----------------------------------------
Feature #21572: Make illegal variable in alternation pattern a syntax error
https://bugs.ruby-lang.org/issues/21572#change-114625
* Author: kddnewton (Kevin Newton)
* Status: Open
----------------------------------------
Currently when you have an illegal variable in an alternation pattern, you get a compile error, but no syntax error.
```ruby
case foo
in {a: } | Array
"matched: #{a}"
end
```
yields
```
$ ruby -cv test.rb
ruby 3.5.0dev (2025-04-10T10:21:51Z master 756479324f) +PRISM [x86_64-linux]
Syntax OK
```
but
```
$ ruby test.rb
test.rb:2: illegal variable in alternative pattern (a)
test.rb: compile error (SyntaxError)
```
Looking at the compiler, since illegal jumps (like break, next, etc.) are now syntax errors, the only other actual compiler errors are related to builtins. I think this should be a proper syntax error, so that editors and other tools can report on it and users can find it in development sooner.
--
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] 6+ messages in thread* [ruby-core:123283] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error
2025-09-13 14:14 [ruby-core:123241] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error kddnewton (Kevin Newton) via ruby-core
2025-09-16 10:15 ` [ruby-core:123259] " Earlopain (Earlopain _) via ruby-core
@ 2025-09-17 16:45 ` kddnewton (Kevin Newton) via ruby-core
2025-10-21 15:45 ` [ruby-core:123511] " ktsj (Kazuki Tsujimoto) via ruby-core
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-09-17 16:45 UTC (permalink / raw)
To: ruby-core; +Cc: kddnewton (Kevin Newton)
Issue #21572 has been updated by kddnewton (Kevin Newton).
I agree, but there's precedence here of some things only being detectable at run-time, like illegal `break` usage. I just want to make sure this change goes through the proper channels to make sure everyone is onboard.
----------------------------------------
Feature #21572: Make illegal variable in alternation pattern a syntax error
https://bugs.ruby-lang.org/issues/21572#change-114654
* Author: kddnewton (Kevin Newton)
* Status: Open
----------------------------------------
Currently when you have an illegal variable in an alternation pattern, you get a compile error, but no syntax error.
```ruby
case foo
in {a: } | Array
"matched: #{a}"
end
```
yields
```
$ ruby -cv test.rb
ruby 3.5.0dev (2025-04-10T10:21:51Z master 756479324f) +PRISM [x86_64-linux]
Syntax OK
```
but
```
$ ruby test.rb
test.rb:2: illegal variable in alternative pattern (a)
test.rb: compile error (SyntaxError)
```
Looking at the compiler, since illegal jumps (like break, next, etc.) are now syntax errors, the only other actual compiler errors are related to builtins. I think this should be a proper syntax error, so that editors and other tools can report on it and users can find it in development sooner.
--
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] 6+ messages in thread* [ruby-core:123511] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error
2025-09-13 14:14 [ruby-core:123241] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error kddnewton (Kevin Newton) via ruby-core
2025-09-16 10:15 ` [ruby-core:123259] " Earlopain (Earlopain _) via ruby-core
2025-09-17 16:45 ` [ruby-core:123283] " kddnewton (Kevin Newton) via ruby-core
@ 2025-10-21 15:45 ` ktsj (Kazuki Tsujimoto) via ruby-core
2025-10-22 14:58 ` [ruby-core:123524] " kddnewton (Kevin Newton) via ruby-core
2025-10-23 13:57 ` [ruby-core:123537] " nobu (Nobuyoshi Nakada) via ruby-core
4 siblings, 0 replies; 6+ messages in thread
From: ktsj (Kazuki Tsujimoto) via ruby-core @ 2025-10-21 15:45 UTC (permalink / raw)
To: ruby-core; +Cc: ktsj (Kazuki Tsujimoto)
Issue #21572 has been updated by ktsj (Kazuki Tsujimoto).
I agree with you, @kddnewton.
Your proposal makes sense.
----------------------------------------
Feature #21572: Make illegal variable in alternation pattern a syntax error
https://bugs.ruby-lang.org/issues/21572#change-114884
* Author: kddnewton (Kevin Newton)
* Status: Open
----------------------------------------
Currently when you have an illegal variable in an alternation pattern, you get a compile error, but no syntax error.
```ruby
case foo
in {a: } | Array
"matched: #{a}"
end
```
yields
```
$ ruby -cv test.rb
ruby 3.5.0dev (2025-04-10T10:21:51Z master 756479324f) +PRISM [x86_64-linux]
Syntax OK
```
but
```
$ ruby test.rb
test.rb:2: illegal variable in alternative pattern (a)
test.rb: compile error (SyntaxError)
```
Looking at the compiler, since illegal jumps (like break, next, etc.) are now syntax errors, the only other actual compiler errors are related to builtins. I think this should be a proper syntax error, so that editors and other tools can report on it and users can find it in development sooner.
--
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] 6+ messages in thread* [ruby-core:123524] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error
2025-09-13 14:14 [ruby-core:123241] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error kddnewton (Kevin Newton) via ruby-core
` (2 preceding siblings ...)
2025-10-21 15:45 ` [ruby-core:123511] " ktsj (Kazuki Tsujimoto) via ruby-core
@ 2025-10-22 14:58 ` kddnewton (Kevin Newton) via ruby-core
2025-10-23 13:57 ` [ruby-core:123537] " nobu (Nobuyoshi Nakada) via ruby-core
4 siblings, 0 replies; 6+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2025-10-22 14:58 UTC (permalink / raw)
To: ruby-core; +Cc: kddnewton (Kevin Newton)
Issue #21572 has been updated by kddnewton (Kevin Newton).
Thank you @ktsj — I will start working on a patch for Prism.
----------------------------------------
Feature #21572: Make illegal variable in alternation pattern a syntax error
https://bugs.ruby-lang.org/issues/21572#change-114900
* Author: kddnewton (Kevin Newton)
* Status: Open
----------------------------------------
Currently when you have an illegal variable in an alternation pattern, you get a compile error, but no syntax error.
```ruby
case foo
in {a: } | Array
"matched: #{a}"
end
```
yields
```
$ ruby -cv test.rb
ruby 3.5.0dev (2025-04-10T10:21:51Z master 756479324f) +PRISM [x86_64-linux]
Syntax OK
```
but
```
$ ruby test.rb
test.rb:2: illegal variable in alternative pattern (a)
test.rb: compile error (SyntaxError)
```
Looking at the compiler, since illegal jumps (like break, next, etc.) are now syntax errors, the only other actual compiler errors are related to builtins. I think this should be a proper syntax error, so that editors and other tools can report on it and users can find it in development sooner.
--
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] 6+ messages in thread* [ruby-core:123537] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error
2025-09-13 14:14 [ruby-core:123241] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error kddnewton (Kevin Newton) via ruby-core
` (3 preceding siblings ...)
2025-10-22 14:58 ` [ruby-core:123524] " kddnewton (Kevin Newton) via ruby-core
@ 2025-10-23 13:57 ` nobu (Nobuyoshi Nakada) via ruby-core
4 siblings, 0 replies; 6+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2025-10-23 13:57 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
Issue #21572 has been updated by nobu (Nobuyoshi Nakada).
https://github.com/ruby/ruby/pull/14923
----------------------------------------
Feature #21572: Make illegal variable in alternation pattern a syntax error
https://bugs.ruby-lang.org/issues/21572#change-114913
* Author: kddnewton (Kevin Newton)
* Status: Open
----------------------------------------
Currently when you have an illegal variable in an alternation pattern, you get a compile error, but no syntax error.
```ruby
case foo
in {a: } | Array
"matched: #{a}"
end
```
yields
```
$ ruby -cv test.rb
ruby 3.5.0dev (2025-04-10T10:21:51Z master 756479324f) +PRISM [x86_64-linux]
Syntax OK
```
but
```
$ ruby test.rb
test.rb:2: illegal variable in alternative pattern (a)
test.rb: compile error (SyntaxError)
```
Looking at the compiler, since illegal jumps (like break, next, etc.) are now syntax errors, the only other actual compiler errors are related to builtins. I think this should be a proper syntax error, so that editors and other tools can report on it and users can find it in development sooner.
--
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] 6+ messages in thread