#420 √ resolved
Wilson Bilkovich

Parser handles pathological regexp ambiguity poorly

Reported by Wilson Bilkovich | March 14th, 2008 @ 12:07 PM | in 1.0 preview

Given this code:

whatever = 50
whatever /25 ; #/ ; raise "Wrong!"

puts "Safe!"

Ruby 1.8.6 prints 'Safe!', Rubinius currently raises a NameError.

Comments and changes to this ticket

  • Brian Ford

    Brian Ford November 25th, 2008 @ 02:47 PM

    • → Tag changed from “” to “compatibility compiler”
    • → State changed from “new” to “resolved”

    This appears to be fixed:

    
    euler:rubinius brian$ parse_tree_show r.rb
    r.rb:2: warning: useless use of / in void context
    s(:block,
     s(:lasgn, :whatever, s(:lit, 50)),
     s(:call, s(:lvar, :whatever), :/, s(:arglist, s(:lit, 25))),
     s(:call, nil, :puts, s(:arglist, s(:str, "Safe!"))))
    euler:rubinius brian$ ruby r.rb
    Safe!
    euler:rubinius brian$ SYDNEY=1 bin/rbx describe r.rb File: r.rb
    Sexp:
    s(:block,
     s(:lasgn, :whatever, s(:lit, 50)),
     s(:call, s(:lvar, :whatever), :/, s(:arglist, s(:lit, 25))),
     s(:call, nil, :puts, s(:arglist, s(:str, "Safe!"))))
    
    Compiled output:
    ============ :__script__ =============
    object_id: 0x28
    total args: 0 required: 0
    stack size: 3, local count: 1
    
    0000:  push_int                   50
    0002:  set_local                  0    # whatever
    0004:  pop
    0005:  push_local                 0    # whatever
    0007:  push_int                   25
    0009:  send_stack                 #<SendSite:0x40 name=/ hits=0 misses=0>, 1
    0012:  pop
    0013:  push_self
    0014:  push_literal               "Safe!"
    0016:  string_dup
    0017:  set_call_flags             1
    0019:  send_stack                 #<SendSite:0x4e name=puts hits=0 misses=0>, 1
    0022:  pop
    0023:  push_true
    0024:  ret
    --------------------------------------
    euler:rubinius brian$ SYDNEY=1 bin/rbx r.rb
    Safe!
    euler:rubinius brian$ cat r.rb
    whatever = 50
    whatever /25 ; #/ ; raise "Wrong!"
    
    puts "Safe!"
    

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »