Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

The compiler shouldn't yell at a call to a subroutine that has been wrapped by a trait in Rakudo #3727

Open p6rt opened 9 years ago

p6rt commented 9 years ago

Migrated from rt.perl.org#124036 (status was 'open')

Searchable as RT124036$

p6rt commented 9 years ago

From @masak

\ m​: sub trait_mod​:\(&c, :$curried!) { my $arity = &c.arity; &c.wrap(-> |args { args.list.elems == $arity ?? callsame() !! &c.assuming(|args); }); }; sub foo($a, $b) is curried { say $a + $b; }; foo(3, 4); my $c = foo(5); $c(6); \ rakudo-moar f8002f​: OUTPUT«===SORRY!=== Error while compiling /tmp/CqAnyz9U98␤Calling 'foo' will never work with argument types (int)␤ Expected​: :(Any $a, Any $b)␤at /tmp/CqAnyz9U98​:1␤------> ed { say $a + $b; }; foo(3, 4); my $c = ⏏foo(5); $c(6);␤» \ if an "is" wraps a sub, then it probably shouldnt get checked :) * masak can't decide who is right, Ven or Rakudo \ probably Ven. * masak submits rakudobug \ :D \ Ven​: it is seldom this close. congratulations. \ thanks, I guess * psch agrees \ m​: sub trait_mod​:\(&c, :$curried!) { my $arity = &c.arity; &c.wrap(-> |args { args.list.elems == $arity ?? callsame() !! &c.assuming(|args); }); }; my &foo = sub ($a, $b) is curried { say $a + $b; }; foo(3)(4) # seeing as this works \ rakudo-moar f8002f​: OUTPUT«7␤» \ psch++ \ but then we can't rebind a normal sub declaration either \ which i think was justified with "it would break optimisation" \ having the distinction makes "sub foo { }" somewhat magical over "my &foo = sub { }", which is surprising, and with the bit of jnthn++'s FOSDEM talk that i watched yesterday even seems wrong, because "sub foo { }" is supposed to be just a lexical declaration (unless there was more that i missed)

p6rt commented 6 years ago

From @AlexDaniel

Still same error message (2017.11,HEAD(e5b660e))

On 2015-03-10 09​:12​:23, masak wrote​:

\ m​: sub trait_mod​:\(&c, :$curried!) { my $arity = &c.arity; &c.wrap(-> |args { args.list.elems == $arity ?? callsame() !! &c.assuming(|args); }); }; sub foo($a, $b) is curried { say $a + $b; }; foo(3, 4); my $c = foo(5); $c(6); \ rakudo-moar f8002f​: OUTPUT«===SORRY!=== Error while compiling /tmp/CqAnyz9U98␤Calling 'foo' will never work with argument types (int)␤ Expected​: :(Any $a, Any $b)␤at /tmp/CqAnyz9U98​:1␤------> ed { say $a + $b; }; foo(3, 4); my $c = ⏏foo(5); $c(6);␤» \ if an "is" wraps a sub, then it probably shouldnt get checked :) * masak can't decide who is right, Ven or Rakudo \ probably Ven. * masak submits rakudobug \ :D \ Ven​: it is seldom this close. congratulations. \ thanks, I guess * psch agrees \ m​: sub trait_mod​:\(&c, :$curried!) { my $arity = &c.arity; &c.wrap(-> |args { args.list.elems == $arity ?? callsame() !! &c.assuming(|args); }); }; my &foo = sub ($a, $b) is curried { say $a + $b; }; foo(3)(4) # seeing as this works \ rakudo-moar f8002f​: OUTPUT«7␤» \ psch++ \ but then we can't rebind a normal sub declaration either \ which i think was justified with "it would break optimisation" \ having the distinction makes "sub foo { }" somewhat magical over "my &foo = sub { }", which is surprising, and with the bit of jnthn++'s FOSDEM talk that i watched yesterday even seems wrong, because "sub foo { }" is supposed to be just a lexical declaration (unless there was more that i missed)

p6rt commented 6 years ago

The RT System itself - Status changed from 'new' to 'open'