ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: "kddnewton (Kevin Newton) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "kddnewton (Kevin Newton)" <noreply@ruby-lang.org>
Subject: [ruby-core:123241] [Ruby Feature#21572] Make illegal variable in alternation pattern a syntax error
Date: Sat, 13 Sep 2025 14:14:24 +0000 (UTC)	[thread overview]
Message-ID: <redmine.issue-21572.20250913141424.10206@ruby-lang.org> (raw)
In-Reply-To: <redmine.issue-21572.20250913141424.10206@ruby-lang.org>

Issue #21572 has been reported by kddnewton (Kevin Newton).

----------------------------------------
Feature #21572: Make illegal variable in alternation pattern a syntax error
https://bugs.ruby-lang.org/issues/21572

* 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/

       reply	other threads:[~2025-09-13 14:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-13 14:14 kddnewton (Kevin Newton) via ruby-core [this message]
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 ` [ruby-core:123511] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.issue-21572.20250913141424.10206@ruby-lang.org \
    --to=ruby-core@ml.ruby-lang.org \
    --cc=noreply@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).