Rick DeNatale wrote:
> Hmmmm, not so sure that that's actually a bug.
It's a bug
Here the bytecode
vgs% ./ruby -ve 'puts
VM::InstructionSequence.compile("defined?(a.b)").disasm'
ruby 1.9.0 (2008-03-21 revision 15825) [i686-linux]
<compiled>:1: warning: useless use of defined? in void context
== disasm: <ISeq:<compiled>@<compiled>>=================================
0000 putself ( 1)
0001 defined 21, :a, false
0005 leave
0006 pop
0007 branchif 12
0009 putnil
0010 leave
0011 pop
0012 putnil
0013 send :a, 0, nil, 24, <ic>
0019 defined 13, :b, true
0023 leave
vgs%
Now if I add 'p'
vgs% ./ruby -ve 'puts VM::InstructionSequence.compile("p
defined?(a.b)").disasm'
ruby 1.9.0 (2008-03-21 revision 15825) [i686-linux]
== disasm: <ISeq:<compiled>@<compiled>>=================================
0000 putnil ( 1)
0001 putself
0002 defined 21, :a, false
0006 jump 24
0008 branchif 13
0010 putnil
0011 jump 24
0013 putnil
0014 send :a, 0, nil, 24, <ic>
0020 defined 13, :b, true
0024 send :p, 1, nil, 8, <ic>
0030 leave
vgs%
See the bytecode 'jump 24' in 0006
Guy Decoux