From: merch-redmine@... Date: 2021-05-14T00:15:13+00:00 Subject: [ruby-core:103839] [Ruby master Bug#17724] Pattern matching error message is confusing Issue #17724 has been updated by jeremyevans0 (Jeremy Evans). I've added a pull request to directly support instance/class/global variables with the pin operator: https://github.com/ruby/ruby/pull/4502 You could already use all of those variables with the pin expression support by surrounding them in parantheses. However, since local variables and constants are supported, I think it makes sense to also support instance/class/global variables directly. I don't think it makes sense to support methods, as doing so is much more complex (arguments/blocks). Users can use the pin expression support for methods. My approach to fixing this bug is really introducing a new feature so the bug reported (confusing error message) isn't a problem anymore. Since this changes the pattern matching syntax, it probably should be approved by both @ktsj and @matz). ---------------------------------------- Bug #17724: Pattern matching error message is confusing https://bugs.ruby-lang.org/issues/17724#change-91958 * Author: jnchito (Junichi Ito) * Status: Assigned * Priority: Normal * Assignee: ktsj (Kazuki Tsujimoto) * 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/ Unsubscribe: