On Mon Oct 10 17:20:53 2011, coke wrote:
> On Sat Mar 06 05:23:08 2010, masak wrote:
> > <masak> when I write 'our sub foo', the scope of the parameters in
> the
> > signature of foo is a global scope rather than a lexical scope, yes?
> > <TimToady> uh, no
> > <TimToady> only 'foo' is aliased
> > <masak> so, how about this?
> > <masak> rakudo: my $a = 1; sub foo() { my $a = 2; our sub bar($x
> where
> > $a) { say $x } }; bar(1); bar(2)
> > <p6eval> rakudo 974d9a: OUTPUT«1␤Constraint type check failed for
> > parameter '$x' [...]
> > <TimToady> looks like it's getting the wrong $a to me
> > * masak submits rakudobug
> > <TimToady> ($a isn't a parameter though)
> > <pmichaud> sub foo() { my $a = 2; our sub bar($x where $a) { say $x
> }
> > }; bar(2);
> > <pmichaud> rakudo: sub foo() { my $a = 2; our sub bar($x where $a) {
> > say $x } }; bar(2);
> > <p6eval> rakudo 974d9a: OUTPUT«Symbol '$a' not predeclared in bar
> > [...]
> > <pmichaud> looks like the where clause is attached to the wrong
> outer
> > scope
> > <TimToady> it does at that
> 
> Current behavior:
> 
> 20:20 < [Coke]> rakudo: my $a = 1; sub foo() { my $a = 2; our sub
> bar($x where
>                 $a) { say $x } }; bar(1); bar(2)
> 20:20 <+p6eval> rakudo 38907e: OUTPUT«Could not find sub &bar␤  in
> block <anon>
>                 at /tmp/XCB2X1q5A9:1␤  in <anon> at
> /tmp/XCB2X1q5A9:1␤»
> 20:20 < [Coke]> rakudo: sub foo() { my $a = 2; our sub bar($x where
> $a) { say
>                 $x } }; bar(2);
> 20:20 <+p6eval> rakudo 38907e: OUTPUT«Could not find sub &bar␤  in
> block <anon>
>                 at /tmp/hSS1YJsEDY:1␤  in <anon> at
> /tmp/hSS1YJsEDY:1␤»

<masak> https://rt.perl.org/rt3/Ticket/Display.html?id=73344 needs 
reformulating because 'our' subs don't work that way anymore.
<masak> not sure the same behaviour can be had with the new 'our' sub 
semantics.
<moritz> masak: just return sub bar from sub foo
<masak> moritz++: I'll try that
<masak> rakudo: my $a = 1; sub foo { my $a = 2; sub bar($x where $a) { 
say "called with $x" }; &bar }; foo()(2); foo()(1)
<p6eval> rakudo 38907e: OUTPUT«called with 2␤Constraint type check 
failed for parameter '$x' [...]
<moritz> rakudo: my $a = 1; sub foo() { my $a = 2; sub bar($x where $a) 
{ say $x } }; my &bar := foo; bar(1)
<p6eval> rakudo 38907e: OUTPUT«Constraint type check failed for 
parameter '$x' [...]
<masak> all indications point to it working nowadays.
* masak adds that to the ticket

Can be closed module needstests.

Reply via email to