On Mon, Sep 06, 2010 at 12:35:58AM -0000, Parrot wrote:
> Comment(by plobsing):
> There are 2 primary causes for the lookup failure:
> - the main sub does not remember that it is an outer sub
> (SUB_FLAG_IS_OUTER is not preserved)
> - the freeze/thaw process creates a clone of the main sub as the
> exit_handler sub's outer_sub attribute. The clone does not have its ->ctx
> field updated (only the original gets the update)
>
> On a higher level though, something smells wrong with using the outer
> sub's ->ctx attribute for much of anything, let alone using it for
> find_lex lookups.
The ->ctx attribute on subs is a long-standing feature known as
"autoclose". In fact, the problem is resolved if 'main' correctly
does a capture_lex on its inner sub (as all lexical outers are
supposed to do to their inner subs):
pmich...@plum:~/parrot/trunk$ cat x.pir
.sub main :main
.const 'Sub' $P0 = 'f'
capture_lex $P0
.local pmc a
.lex 'a', a
a = new ['Integer']
a = 42
f()
.end
.sub f :outer(main)
.local pmc a
a = find_lex 'a'
say a
.end
pmich...@plum:~/parrot/trunk$ ./parrot -o x.pbc x.pir
pmich...@plum:~/parrot/trunk$ ./parrot x.pbc
42
pmich...@plum:~/parrot/trunk$
With the capture_lex in place, I'd lean towards closing
this as a non-bug.
Pm
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets