ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:102851] [Ruby master Bug#17724] Pattern matching error message is confusing
@ 2021-03-15  1:40 me
  2021-03-15  2:57 ` [ruby-core:102855] " marcandre-ruby-core
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: me @ 2021-03-15  1:40 UTC (permalink / raw)
  To: ruby-core

Issue #17724 has been reported by jnchito (Junichi Ito).

----------------------------------------
Bug #17724: Pattern matching error message is confusing
https://bugs.ruby-lang.org/issues/17724

* Author: jnchito (Junichi Ito)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
When I use pattern match with instance variables, I get an error message like "expecting local variable or method"

``` ruby
@n = 1
case 1
in ^@n
  # ...
end
#=> syntax error, unexpected instance variable, expecting local variable or method (SyntaxError)
#   in ^@n
#       ^~
```

However using method is not allowed, either.

``` ruby
def n = 1
case 1
in ^n
  # ...
end
#=> n: no such local variable (SyntaxError)
```

I think the message "expecting local variable or method" is confusing and should be fixed like "expecting local variable."




-- 
https://bugs.ruby-lang.org/

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

end of thread, other threads:[~2021-07-15  5:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15  1:40 [ruby-core:102851] [Ruby master Bug#17724] Pattern matching error message is confusing me
2021-03-15  2:57 ` [ruby-core:102855] " marcandre-ruby-core
2021-04-11  7:08 ` [ruby-core:103384] " kazuki
2021-05-14  0:15 ` [ruby-core:103839] " merch-redmine
2021-05-16  8:13 ` [ruby-core:103860] [Ruby master Feature#17724] Make the pin operator support instance/class/global variables kazuki
2021-07-15  5:42 ` [ruby-core:104608] " matz

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).