Hi,

I'm trying to use RubyVM::InstructionSequence to play around with bytecode.
To do something useful with it, I want to convert a sequence to an array.
There is a to_a method on instructionsequences, which works great.

After some playing with it, I noticed some code could not get translated.
I tracked the problem down and found it's related to using strings.
As long as I don't use any strings in scripts, everything works fine.
Using a string however triggers a strange problem.

I tried some different scripts and found that the problem lies in the
'putstring' opcode.

puts RubyVM::InstructionSequence.new("puts 'Hello, world!'").disasm
== disasm: <RubyVM::InstructionSequence:<compiled>@<compiled>>==========
0000 trace            1                                               (   1)
0002 putnil
0003 putstring        "Hello, world!"
0005 send             :puts, 1, nil, 8, <ic>
0011 leave
=> nil

Looks like the sequence is ok, but when converting it to an array, I get this:

puts RubyVM::InstructionSequence.new("puts 'Hello, world!'").to_a
YARVInstructionSequence/SimpleDataFormat
1
1
1
{:arg_size=>0, :local_size=>1, :stack_max=>2}
<compiled>
<compiled>
top
0
1
trace
1
putnil
putstring
NotImplementedError: method `respond_to?' called on terminated object
(0x000000016e45f0)
	from (irb):2:in `puts'
	from (irb):2:in `puts'
	from (irb):2
	from /opt/ruby-1.9/bin/irb:12:in `<main>'

I'm on ubuntu 9.04 64bit
I didn't use any special CFLAGS or options for ./configure.

Can anyone confirm this?
Is there a solution/workaround for this problem?

Thanks,
Mathijs