From: Mauricio Fernandez Date: 2006-02-13T00:07:06+09:00 Subject: Re: Parse error within Regexp On Sun, Feb 12, 2006 at 09:47:24PM +0900, dblack@wobblini.net wrote: > >Besides, consider this case: > > > >$ ruby19 -e 'puts ARGF.read.scan /[-+]?(\d+(?:\.\d+)?)(?=[^\d])' > >-e:1: warning: ambiguous first argument; put parentheses or even spaces > >-e:1: unterminated string meets end of file > >-e:1: syntax error, unexpected tSTRING_END, expecting tSTRING_CONTENT or > >tREGEXP_END or tSTRING_DBEG or tSTRING_DVAR > > > >I think the following makes more sense and is less noisy too: > > > >~/src/ruby/ruby.head$ ./ruby19 -e 'puts ARGF.read.scan > >/[-+]?(\d+(?:\.\d+)?)(?=[^\d])' > >-e:1: warning: ambiguous first argument; put parentheses or even spaces > >-e:1: unterminated regexp meets end of file > >-e:1: warning: parenthesize argument(s) for future version > > That's a different case, though: that's truly an unterminated regexp. The point is that both cases (actual, and spurious unterminated regexp due to '/' being interpreted as a division) are handled by the same code in parse.y. The patch in [7340] clarifies the error message in the above situation and does no harm in the other case (if anything, it makes it slightly less confusing because one won't be left wondering where the "unterminated string" is), which is the reason why it was written in the first place. -- Mauricio Fernandez