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

Using the special ClassName{ :key($value) } syntax inside .new doesn't work in Rakudo #2236

Open
p6rt opened this issue Oct 28, 2010 · 9 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 28, 2010

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

Searchable as RT78676$

@p6rt
Copy link
Author

p6rt commented Jul 13, 2010

From @moritz

In the course of the 'ng' branch, Rakudo has regressed on passing parent
attributes to constructors.

Tests can be found in t/spec/S12-construction/new.t

@p6rt
Copy link
Author

p6rt commented Jul 29, 2010

@coke - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 28, 2010

From @masak

<masak> rakudo​: class A { has $.x; method foo { say $!x } }; class B
is A { has $.x; method bar { say $!x } }; B.new(​:x(42), A{ :x(5) })
<p6eval> rakudo 479650​: OUTPUT«flattened parameters must be a hash or
array [...]
<masak> jnthn​: whoz op with that?
<jnthn> rakudo​: class A { }; class B { }; B.new(A{ :x(5) })
<p6eval> rakudo 479650​: OUTPUT«flattened parameters must be a hash or
array [...]
<jnthn> Hm
<jnthn> masak​: Off hand, I'm not sure.
<jnthn> masak​: Unless it's a general WHENCE issue.
<masak> but it's a bug, right?
<jnthn> Yeah
* masak submits rakudobug
<jnthn> I wonder if we're missing A{ ... } support somehow.
<masak> I'm pretty sure it worked at some point.
<masak> not sure it ever worked in master, though.

@p6rt
Copy link
Author

p6rt commented Jan 1, 2011

From @masak

<masak> rakudo​: class A { has $.val }; class B is A { has $.val }; my
$b = B.new(A{ :val("A") }); say "alive"
<p6eval> rakudo b570a2​: OUTPUT«flattened parameters must be a hash or
array␤ in main program body at line 22​:/tmp/DYw5OTlNCI␤»
<masak> this should work, no?
<masak> I think it even used to...
<masak> alpha​: class A { has $.val }; class B is A { has $.val }; my
$b = B.new(A{ :val("A") }); say $b.A​::val
<p6eval> alpha : OUTPUT«Use of uninitialized value␤␤»
* masak submits rakudobug

alpha didn't get the accessor right, but it parses the constructor
syntax without a problem. There are spectests for this in
S12-construction/new.t, but they're TODO'd.

@p6rt
Copy link
Author

p6rt commented Feb 26, 2014

From @coke

On Thu Oct 28 14​:41​:06 2010, masak wrote​:

<masak> rakudo​: class A { has $.x; method foo { say $!x } }; class B
is A { has $.x; method bar { say $!x } }; B.new(​:x(42), A{ :x(5) })
<p6eval> rakudo 479650​: OUTPUT«flattened parameters must be a hash or
array [...]
<masak> jnthn​: whoz op with that?
<jnthn> rakudo​: class A { }; class B { }; B.new(A{ :x(5) })
<p6eval> rakudo 479650​: OUTPUT«flattened parameters must be a hash or
array [...]
<jnthn> Hm
<jnthn> masak​: Off hand, I'm not sure.
<jnthn> masak​: Unless it's a general WHENCE issue.
<masak> but it's a bug, right?
<jnthn> Yeah
* masak submits rakudobug
<jnthn> I wonder if we're missing A{ ... } support somehow.
<masak> I'm pretty sure it worked at some point.
<masak> not sure it ever worked in master, though.

This now dies with​:

Default constructor for 'B' only takes named arguments

Is this acceptable?

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Feb 26, 2014

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

@p6rt
Copy link
Author

p6rt commented Feb 26, 2014

From @masak

On Wed, Feb 26, 2014 at 1​:50 AM, Will Coleda via RT
<perl6-bugs-followup@​perl.org> wrote​:

On Thu Oct 28 14​:41​:06 2010, masak wrote​:

<masak> rakudo​: class A { has $.x; method foo { say $!x } }; class B
is A { has $.x; method bar { say $!x } }; B.new(​:x(42), A{ :x(5) })
<p6eval> rakudo 479650​: OUTPUT«flattened parameters must be a hash or
array [...]
<masak> jnthn​: whoz op with that?
<jnthn> rakudo​: class A { }; class B { }; B.new(A{ :x(5) })
<p6eval> rakudo 479650​: OUTPUT«flattened parameters must be a hash or
array [...]
<jnthn> Hm
<jnthn> masak​: Off hand, I'm not sure.
<jnthn> masak​: Unless it's a general WHENCE issue.
<masak> but it's a bug, right?
<jnthn> Yeah
* masak submits rakudobug
<jnthn> I wonder if we're missing A{ ... } support somehow.
<masak> I'm pretty sure it worked at some point.
<masak> not sure it ever worked in master, though.

This now dies with​:

Default constructor for 'B' only takes named arguments

Is this acceptable?

It shouldn't die, it should be a legal way to construct a B object
with an assignment to the (shadowed) $!x in A.

@p6rt
Copy link
Author

p6rt commented May 7, 2015

From @FROGGS

class Foo { has $.x is rw }; class Bar is Foo { }; my Foo $u .= new(​:5x); say $u.x; $u = Bar.new(Foo{​:12x});
rakudo-moar a34d02​: OUTPUT«5␤Default constructor for 'Bar' only takes named arguments␤ in block <unit> at /tmp/FrBrn8xOI_​:1␤␤»

I guess this needs to translate to something else than Any in order to make it work​:
class Foo { }; say (Foo{​:12x})
rakudo-moar a34d02​: OUTPUT«(Any)␤»

@p6rt
Copy link
Author

p6rt commented Dec 18, 2015

From @jnthn

On Thu May 07 02​:51​:39 2015, FROGGS.de wrote​:

class Foo { has $.x is rw }; class Bar is Foo { }; my Foo $u .=
new(​:5x); say $u.x; $u = Bar.new(Foo{​:12x});
rakudo-moar a34d02​: OUTPUT«5␤Default constructor for 'Bar' only takes
named arguments␤ in block <unit> at /tmp/FrBrn8xOI_​:1␤␤»

I guess this needs to translate to something else than Any in order to
make it work​:
class Foo { }; say (Foo{​:12x})
rakudo-moar a34d02​: OUTPUT«(Any)␤»

We actually weren't recognizing the auto-vivifying closure syntax at all. I've now reserved it, so we can implement this feature in a future version of the Perl 6 language. It's not being missed too hard, and I don't want to rush in a half-baked implementation of it for 6.Christmas.

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant