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

Role type objects don't trigger the rhs in infix:<//> in Rakudo #3014

Closed
p6rt opened this issue Dec 28, 2012 · 5 comments
Closed

Role type objects don't trigger the rhs in infix:<//> in Rakudo #3014

p6rt opened this issue Dec 28, 2012 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Dec 28, 2012

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

Searchable as RT116230$

@p6rt
Copy link
Author

p6rt commented Dec 28, 2012

From @masak

<doy> r​: role Foo { }; class Bar { has Foo $.foo; method baz { my $foo
= $!foo; my $replacement = Foo.new; say $replacement.defined; say
$foo.defined; $foo //= $replacement; say $foo.defined } }; Bar.new.baz
<p6eval> rakudo 930369​: OUTPUT«True␤False␤False␤»
<doy> role type constraints seem to break things
* masak submits rakudobug
<masak> r​: role Foo {}; my $x = Foo; $x //= Foo.new; say $x.defined
<p6eval> rakudo 930369​: OUTPUT«False␤»
<masak> r​: role Foo {}; say Foo.new.defined
<p6eval> rakudo 930369​: OUTPUT«True␤»
<masak> yeah. definitely something wrong there.
<masak> r​: role Foo {}; my $x = Foo; $x = $x // Foo.new; say $x.defined
<p6eval> rakudo 930369​: OUTPUT«False␤»

It is my expectation that when something undefined occurs on the lhs
of the infix​:<//> operator, the rhs should be the result.

@p6rt
Copy link
Author

p6rt commented Jan 11, 2013

From @jnthn

On Fri Dec 28 10​:51​:13 2012, masak wrote​:

<doy> r​: role Foo { }; class Bar { has Foo $.foo; method baz { my $foo
= $!foo; my $replacement = Foo.new; say $replacement.defined; say
$foo.defined; $foo //= $replacement; say $foo.defined } }; Bar.new.baz
<p6eval> rakudo 930369​: OUTPUT«True␤False␤False␤»
<doy> role type constraints seem to break things
* masak submits rakudobug
<masak> r​: role Foo {}; my $x = Foo; $x //= Foo.new; say $x.defined
<p6eval> rakudo 930369​: OUTPUT«False␤»
<masak> r​: role Foo {}; say Foo.new.defined
<p6eval> rakudo 930369​: OUTPUT«True␤»
<masak> yeah. definitely something wrong there.
<masak> r​: role Foo {}; my $x = Foo; $x = $x // Foo.new; say $x.defined
<p6eval> rakudo 930369​: OUTPUT«False␤»

It is my expectation that when something undefined occurs on the lhs
of the infix​:<//> operator, the rhs should be the result.

It was something with the way // was compiled, of all things (down to
the Parrot v-table; thankfully, QAST allows HLL overrides of anything,
so I just made the Rakudo compilation of it call .defined).

role Foo {}; my $x = Foo; $x //= Foo.new; say $x.defined
True

Tagging testneeded.

/jnthn

@p6rt
Copy link
Author

p6rt commented Jan 11, 2013

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

@p6rt
Copy link
Author

p6rt commented Jan 12, 2013

From @moritz

Now tested in S03-operators/short-circuit.t.

@p6rt
Copy link
Author

p6rt commented Jan 12, 2013

@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