petdance/scratch — Issue #4: Can't thaw a Sub (or a PIR subclass of a Sub)
Author: petdance
Created: 2011-11-01 05:40:58+00:00
State: open
Labels: bug, core, Pri-normal, Sev-medium

Code:
{{{
.sub main :main

$P0 = get_class 'Sub'
$P1 = subclass $P0, 'myProc'

.local pmc pirC
pirC = compreg 'PIR'

.local string code
code = <<"END_CODE"

.sub bar
say "hi"
.end
END_CODE

.local pmc compiled
compiled = pirC(code)
compiled = compiled[0] # just want the first executable sub here.

compiled() # works

.local pmc sub
sub = new 'myProc'
assign sub, compiled
sub() # works

$S0 = freeze sub
say "frozen"
$P2 = thaw $S0
say "thawed"
$P2()
.end
}}}

Output:
{{{
hi
hi
frozen
Unsupported key type in Key.thaw
current instr.: 'main' pc 48 (borked.pir:30)
}}}

I'd expect to be able to thaw this PMC, and then invoke the sub after thaw.

Originally http://trac.parrot.org/parrot/ticket/132