The attached test case fails in rev 10317 as follows: [EMAIL PROTECTED]> ./parrot -o lex-test-2-sub.pbc lex-test-2-sub.pir [EMAIL PROTECTED]> ./parrot lex-test-2-main.pir parrot: src/hash.c:243: hash_thaw: Assertion `info->extra_flags == EXTRA_IS_COUNT' failed. Aborted [EMAIL PROTECTED]>
The essential feature is that lex-test-2-sub.pir has a sub that is lexically contained within another sub (it was adapted from the 'closure 3' test case, FWIW), which is called from a different compilation unit, where it is loaded as byte code. If "lex-test-2-sub.pbc" is changed to "lex-test-2-sub.pir" in lex-test-2-main.pir, then the code runs as expected: [EMAIL PROTECTED]> ./parrot lex-test-2-main.pir [loaded.] 8 16 [EMAIL PROTECTED]> The upshot is that separate compilation no longer works for code with lexical variables. I'm hoping this is straightforward to fix/finish for someone who understands the code. If not, I'd love to help, but this corner of Parrot is new to me, and so I would need a few clues. TIA, -- Bob Rogers http://rgrjr.dyndns.org/
.sub _foo .param pmc arg .local pmc n .lex '$n', n n = arg .const .Sub anon = "anon" $P0 = newclosure anon .return ($P0) .end .sub anon :outer(_foo) .param pmc arg $P0 = find_lex '$n' # in practice we need copying the arg but as it is passed # as native int, we already have a fresh pmc $P0 += arg .return ($P0) .end
.sub main :main load_bytecode "lex-test-2-sub.pbc" print "[loaded.]\n" .local pmc f f = _foo(5) $P0 = f(3) print $P0 print "\n" $P0 = f(8) print $P0 print "\n" .end