* [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
* [ruby-core:102855] [Ruby master Bug#17724] Pattern matching error message is confusing
2021-03-15 1:40 [ruby-core:102851] [Ruby master Bug#17724] Pattern matching error message is confusing me
@ 2021-03-15 2:57 ` marcandre-ruby-core
2021-04-11 7:08 ` [ruby-core:103384] " kazuki
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marcandre-ruby-core @ 2021-03-15 2:57 UTC (permalink / raw)
To: ruby-core
Issue #17724 has been updated by marcandre (Marc-Andre Lafortune).
Agreed. Ideally instance variable would be allowed, no?
----------------------------------------
Bug #17724: Pattern matching error message is confusing
https://bugs.ruby-lang.org/issues/17724#change-90913
* 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
* [ruby-core:103384] [Ruby master Bug#17724] Pattern matching error message is confusing
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 ` kazuki
2021-05-14 0:15 ` [ruby-core:103839] " merch-redmine
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kazuki @ 2021-04-11 7:08 UTC (permalink / raw)
To: ruby-core
Issue #17724 has been updated by ktsj (Kazuki Tsujimoto).
Assignee set to ktsj (Kazuki Tsujimoto)
Status changed from Open to Assigned
----------------------------------------
Bug #17724: Pattern matching error message is confusing
https://bugs.ruby-lang.org/issues/17724#change-91477
* 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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:103839] [Ruby master Bug#17724] Pattern matching error message is confusing
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 ` 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
4 siblings, 0 replies; 6+ messages in thread
From: merch-redmine @ 2021-05-14 0:15 UTC (permalink / raw)
To: ruby-core
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:103860] [Ruby master Feature#17724] Make the pin operator support instance/class/global variables
2021-03-15 1:40 [ruby-core:102851] [Ruby master Bug#17724] Pattern matching error message is confusing me
` (2 preceding siblings ...)
2021-05-14 0:15 ` [ruby-core:103839] " merch-redmine
@ 2021-05-16 8:13 ` kazuki
2021-07-15 5:42 ` [ruby-core:104608] " matz
4 siblings, 0 replies; 6+ messages in thread
From: kazuki @ 2021-05-16 8:13 UTC (permalink / raw)
To: ruby-core
Issue #17724 has been updated by ktsj (Kazuki Tsujimoto).
Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN)
ruby -v deleted (ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20])
Subject changed from Pattern matching error message is confusing to Make the pin operator support instance/class/global variables
Tracker changed from Bug to Feature
> I think it makes sense to also support instance/class/global variables directly.
I agree.
What do you think, @matz?
----------------------------------------
Feature #17724: Make the pin operator support instance/class/global variables
https://bugs.ruby-lang.org/issues/17724#change-91984
* Author: jnchito (Junichi Ito)
* Status: Assigned
* Priority: Normal
* Assignee: ktsj (Kazuki Tsujimoto)
----------------------------------------
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
* [ruby-core:104608] [Ruby master Feature#17724] Make the pin operator support instance/class/global variables
2021-03-15 1:40 [ruby-core:102851] [Ruby master Bug#17724] Pattern matching error message is confusing me
` (3 preceding siblings ...)
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 ` matz
4 siblings, 0 replies; 6+ messages in thread
From: matz @ 2021-07-15 5:42 UTC (permalink / raw)
To: ruby-core
Issue #17724 has been updated by matz (Yukihiro Matsumoto).
Sounds reasonable. Accepted.
Matz.
----------------------------------------
Feature #17724: Make the pin operator support instance/class/global variables
https://bugs.ruby-lang.org/issues/17724#change-92895
* Author: jnchito (Junichi Ito)
* Status: Assigned
* Priority: Normal
* Assignee: ktsj (Kazuki Tsujimoto)
----------------------------------------
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).