Wrong "ambiguous first argument" warning
$ 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"
Updated by marcandre (Marc-Andre Lafortune) 2 months ago
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?
If so, could we reword the warning to "ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `/' operator"?