Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type capture in signatures captures the wrong thing when rw containers are passed to a routine in Rakudo #2849

Closed
p6rt opened this issue Aug 5, 2012 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Aug 5, 2012

Migrated from rt.perl.org#114394 (status was 'resolved')

Searchable as RT114394$

@p6rt
Copy link
Author

p6rt commented Aug 5, 2012

From @masak

<nebuchadnezzar> hi
<nebuchadnezzar> looking at perl6 book, I tried the examples and find
something curious​: http://pastebin.com/v835G1MD
<nebuchadnezzar> "given" in the sub does not seems to behave the same
way as outside
* masak is looking into it now
<masak> reproduced the bug locally.
<masak> golfing.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 };
sub p($a, $b) { w $a, $b }; say p(R, R); say w(R, R)
<p6eval> ..rakudo 7e1b38​: OUTPUT«-1␤0␤»
* masak submits rakudobug
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 };
(-> $a, $b { say w $a, $b })(R, R); say w R, R
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤0␤»
<masak> correction​: the parameter binding is messing it up somehow.
<jnthn> masak​: Was the issue there with star?
<masak> star​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 };
(-> $a, $b { say w $a, $b })(R, R); say w R, R
<p6eval> star 2012.07​: OUTPUT«-1␤0␤»
<masak> yep.
<jnthn> OK, not a qast related regression then.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 }; my
($a, $b) = (-> $a, $b { $a, $b })(R, R); say w $a, $b
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> curiouser and curiouser.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 }; my
($a, $b) = R, R; say w $a, $b
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> a-ha!
<masak> not parameter binding. variables!
<masak> containers, most like.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 }; my
@​x = R, R; say w(|@​x)
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> aye.
<jnthn> Hm
<jnthn> Can you make it happen without type catpures?
<jnthn> Or are they a necesary part of it?
<masak> I have a hunch they are.
<masak> r​: class R {}; multi w(R, R) { 0 }; multi w($, $) { -1 }; my
@​x = R, R; say w(|@​x)
<p6eval> rakudo 7e1b38​: OUTPUT«0␤»
<masak> aye. they are part of it.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 };
say w(|[R, R])
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> r​: multi w(​::T, T) { 0 }; multi w($, $) { -1 }; say w(|[1, 1])
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> r​: multi w(​::T, T) { 0 }; multi w($, $) { -1 }; say w(1, 1)
<p6eval> rakudo 7e1b38​: OUTPUT«0␤»
* masak loves golfin' :)
<masak> r​: sub w(​::T, T) { 0 }; say w(|[1, 1])
<p6eval> rakudo 7e1b38​: OUTPUT«Nominal type check failed for parameter
''; expected Scalar but got Int instead␤ in sub w [...]
<masak> yay, I tricked Rakudo into telling me what's wrong, even!
<jnthn> masak++ # that makes it rather clearer
* masak does a victory dance

@p6rt
Copy link
Author

p6rt commented Aug 5, 2012

From @jnthn

On Sun Aug 05 08​:18​:18 2012, masak wrote​:

<nebuchadnezzar> hi
<nebuchadnezzar> looking at perl6 book, I tried the examples and find
something curious​: http://pastebin.com/v835G1MD
<nebuchadnezzar> "given" in the sub does not seems to behave the same
way as outside
* masak is looking into it now
<masak> reproduced the bug locally.
<masak> golfing.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 };
sub p($a, $b) { w $a, $b }; say p(R, R); say w(R, R)
<p6eval> ..rakudo 7e1b38​: OUTPUT«-1␤0␤»
* masak submits rakudobug
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 };
(-> $a, $b { say w $a, $b })(R, R); say w R, R
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤0␤»
<masak> correction​: the parameter binding is messing it up somehow.
<jnthn> masak​: Was the issue there with star?
<masak> star​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 };
(-> $a, $b { say w $a, $b })(R, R); say w R, R
<p6eval> star 2012.07​: OUTPUT«-1␤0␤»
<masak> yep.
<jnthn> OK, not a qast related regression then.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 }; my
($a, $b) = (-> $a, $b { $a, $b })(R, R); say w $a, $b
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> curiouser and curiouser.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 }; my
($a, $b) = R, R; say w $a, $b
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> a-ha!
<masak> not parameter binding. variables!
<masak> containers, most like.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 }; my
@​x = R, R; say w(|@​x)
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> aye.
<jnthn> Hm
<jnthn> Can you make it happen without type catpures?
<jnthn> Or are they a necesary part of it?
<masak> I have a hunch they are.
<masak> r​: class R {}; multi w(R, R) { 0 }; multi w($, $) { -1 }; my
@​x = R, R; say w(|@​x)
<p6eval> rakudo 7e1b38​: OUTPUT«0␤»
<masak> aye. they are part of it.
<masak> r​: class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 };
say w(|[R, R])
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> r​: multi w(​::T, T) { 0 }; multi w($, $) { -1 }; say w(|[1, 1])
<p6eval> rakudo 7e1b38​: OUTPUT«-1␤»
<masak> r​: multi w(​::T, T) { 0 }; multi w($, $) { -1 }; say w(1, 1)
<p6eval> rakudo 7e1b38​: OUTPUT«0␤»
* masak loves golfin' :)
<masak> r​: sub w(​::T, T) { 0 }; say w(|[1, 1])
<p6eval> rakudo 7e1b38​: OUTPUT«Nominal type check failed for parameter
''; expected Scalar but got Int instead␤ in sub w [...]
<masak> yay, I tricked Rakudo into telling me what's wrong, even!
<jnthn> masak++ # that makes it rather clearer
* masak does a victory dance

Fixed now​:

sub w(​::T, T) { 0 }; say w(|[1, 1])
0
class R {}; multi w(​::T, T) { 0 }; multi w($, $) { -1 }; sub p($a, $b)
{ w $a, $b }; say p(R, R); say w(R, R)
0
0

Tagging testneeded.

/jnthn

@p6rt
Copy link
Author

p6rt commented Aug 5, 2012

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

@p6rt
Copy link
Author

p6rt commented Aug 7, 2012

From @moritz

Now tested in S06-multi/type-based.t

@p6rt
Copy link
Author

p6rt commented Aug 7, 2012

@moritz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant