[#100689] [Ruby master Feature#17303] Make webrick to bundled gems or remove from stdlib — hsbt@...
Issue #17303 has been reported by hsbt (Hiroshi SHIBATA).
11 messages
2020/11/02
[#100852] [Ruby master Feature#17326] Add Kernel#must! to the standard library — zimmerman.jake@...
Issue #17326 has been reported by jez (Jake Zimmerman).
24 messages
2020/11/14
[#100930] [Ruby master Feature#17333] Enumerable#many? — masafumi.o1988@...
Issue #17333 has been reported by okuramasafumi (Masafumi OKURA).
10 messages
2020/11/18
[#101071] [Ruby master Feature#17342] Hash#fetch_set — hunter_spawn@...
Issue #17342 has been reported by MaxLap (Maxime Lapointe).
26 messages
2020/11/25
[ruby-core:100855] [Ruby master Bug#17124] Wrong "ambiguous first argument" warning
From:
merch-redmine@...
Date:
2020-11-15 06:11:24 UTC
List:
ruby-core #100855
Issue #17124 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Feedback
marcandre (Marc-Andre Lafortune) wrote in #note-3:
> I hadn't thought of `method /a /x` or `method /a /<newline>other_method`, indeed.
>
> This warning is only there when there is ambiguity between two divisions and a regexp literal, right?
No, the warning is used for `+` and `-` in addition to `/`.
> If so, could we reword the warning to "ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `/' operator"?
This requires treating the `/` operator differently than `+` and `-` in terms of the warning. Do you think the benefit is worth the cost?
```diff
--- a/parse.y
+++ b/parse.y
@@ -7788,7 +7788,12 @@ static int
arg_ambiguous(struct parser_params *p, char c)
{
#ifndef RIPPER
- rb_warning1("ambiguous first argument; put parentheses or a space even after `%c' operator", WARN_I(c));
+ if (c == '/') {
+ rb_warning1("ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `%c' operator", WARN_I(c));
+ }
+ else {
+ rb_warning1("ambiguous first argument; put parentheses or a space even after `%c' operator", WARN_I(c));
+ }
#else
dispatch1(arg_ambiguous, rb_usascii_str_new(&c, 1));
#endif
```
----------------------------------------
Bug #17124: Wrong "ambiguous first argument" warning
https://bugs.ruby-lang.org/issues/17124#change-88500
* Author: marcandre (Marc-Andre Lafortune)
* Status: Feedback
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
```sh
$ ruby -v -e "x='a'; x.match? /[a-z]/"
ruby 2.8.0dev (2020-07-30T14:07:06Z master 352895b751) [x86_64-darwin18]
-e:1: warning: ambiguous first argument; put parentheses or a space even after `/' operator
```
There is no `/` operator in there and there is also no ambiguity as adding a space after the first `/` is a syntax error.
Is it possible to remove the warning altogether when the argument is lexed as a regexp?
The message could use a rewording too, maybe "ambiguous first argument; put parentheses around argument or add a space after `/' operator"
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>