String !~ string, not possible in cvshead

While upgrading and reinstalling misc modules I regulary use, I bumped
into this construction. I don’t know if the recent switch from GNU to
Oniguruma has broken anything ?

Any reason that String isn’t allowed anymore ?

ruby a.rb
a.rb:1:in `=~’: type mismatch: String given (TypeError)
from a.rb:1
expand -t2 a.rb
if “hello” !~ "l{2}"
raise
end

Changing right argument into a regexp makes it work.

ruby a.rb
expand -t2 a.rb
if “hello” !~ /l{2}/
raise
end
ruby -v
ruby 1.9.0 (2004-03-31) [i386-freebsd5.1]

Perhaps change exception message to something else, for instance:
in `!~’: right argument must be Regexp, but was String (TypeError)

That would be less confusing :wink:

···


Simon Strandgaard

While upgrading and reinstalling misc modules I regulary use, I bumped
into this construction. I don’t know if the recent switch from GNU to
Oniguruma has broken anything ?

Any reason that String isn’t allowed anymore ?

This behavior was kind of “promised” starting from 1.8:

[mac.gfbm:51]bystr> irb
irb(main):001:0> “aaa” !~ “bbb”
(irb):1: warning: string =~ string will be obsolete; use explicit regexp
=> true
irb(main):002:0>
[mac.gfbm:52]bystr> ruby -v
ruby 1.8.1 (2003-12-25) [powerpc-darwin]

ruby a.rb
a.rb:1:in `=~’: type mismatch: String given (TypeError)
from a.rb:1
expand -t2 a.rb
if “hello” !~ "l{2}"
raise
end

Changing right argument into a regexp makes it work.

ruby a.rb
expand -t2 a.rb
if “hello” !~ /l{2}/
raise
end
ruby -v
ruby 1.9.0 (2004-03-31) [i386-freebsd5.1]

Perhaps change exception message to something else, for instance:
in `!~’: right argument must be Regexp, but was String (TypeError)

That would be less confusing :wink:


Simon Strandgaard

Sincerely,
Gennady Bystritsky

···

On Mar 31, 2004, at 7:49 PM, Simon Strandgaard wrote:

Thanks for the answer.

···

On Thu, 01 Apr 2004 17:22:36 +0900, Gennady Bystritsky wrote:

On Mar 31, 2004, at 7:49 PM, Simon Strandgaard wrote:

While upgrading and reinstalling misc modules I regulary use, I bumped
into this construction. I don’t know if the recent switch from GNU to
Oniguruma has broken anything ?

Any reason that String isn’t allowed anymore ?

This behavior was kind of “promised” starting from 1.8:

[mac.gfbm:51]bystr> irb
irb(main):001:0> “aaa” !~ “bbb”
(irb):1: warning: string =~ string will be obsolete; use explicit regexp
=> true
irb(main):002:0>
[mac.gfbm:52]bystr> ruby -v
ruby 1.8.1 (2003-12-25) [powerpc-darwin]


Simon Strandgaard