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

nextwith and callwith do not work with the .new method in Rakudo #1228

Closed
p6rt opened this issue Aug 15, 2009 · 6 comments
Closed

nextwith and callwith do not work with the .new method in Rakudo #1228

p6rt opened this issue Aug 15, 2009 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Aug 15, 2009

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

Searchable as RT68558$

@p6rt
Copy link
Author

p6rt commented Aug 15, 2009

From @masak

<jnthn> rakudo​: class A { has $.foo; method new($foo) {
nextwith(​:$foo) } }; say A.new("OH HAI").foo
<p6eval> rakudo 0d4fe0​: OUTPUT«too many named arguments - 'foo' not
expected␤in method A​::new
<masak> jnthn​: should that have worked?
<jnthn> Hmm
<jnthn> rakudo​: class A { has $.foo; method new($foo) { say "ok" } };
say A.new("OH HAI")
<p6eval> rakudo 0d4fe0​: OUTPUT«ok␤1␤»
<jnthn> I think so. I'm not quite sure what it tried to call. :-/
* masak submits rakudobug
<jnthn> rakudo​: class A { has $.foo; method new($foo) { callwith($foo)
} }; say A.new("OH HAI").foo
<p6eval> rakudo 0d4fe0​: OUTPUT«Method 'foo' not found for invocant of
class 'Str'␤»
<jnthn> Oh! :-/
<masak> seems to be something to do with the invocant...
<jnthn> Well
<jnthn> Kinda.
<jnthn> Hmm. I'm not sure off-hand why that doesn't work.
<masak> but it should, so it goes on the RT pile.
<jnthn> One of the annoyances of implementing callwith and nextwith is
that in the case of them being used to defer to another method, they
need to find and pass on the invocant.
<jnthn> Whereas in the case of a wrap, they maybe don't.
<masak> ah. tricky.
<jnthn> Yeah.
<jnthn> It'd not surprise me if we have bugs there.

@p6rt
Copy link
Author

p6rt commented Oct 21, 2011

From @coke

On Sat Aug 15 14​:04​:44 2009, masak wrote​:

<jnthn> rakudo​: class A { has $.foo; method new($foo) {
nextwith(​:$foo) } }; say A.new("OH HAI").foo
<p6eval> rakudo 0d4fe0​: OUTPUT«too many named arguments - 'foo' not
expected␤in method A​::new
<masak> jnthn​: should that have worked?
<jnthn> Hmm
<jnthn> rakudo​: class A { has $.foo; method new($foo) { say "ok" } };
say A.new("OH HAI")
<p6eval> rakudo 0d4fe0​: OUTPUT«ok␤1␤»
<jnthn> I think so. I'm not quite sure what it tried to call. :-/
* masak submits rakudobug
<jnthn> rakudo​: class A { has $.foo; method new($foo) { callwith($foo)
} }; say A.new("OH HAI").foo
<p6eval> rakudo 0d4fe0​: OUTPUT«Method 'foo' not found for invocant of
class 'Str'␤»
<jnthn> Oh! :-/
<masak> seems to be something to do with the invocant...
<jnthn> Well
<jnthn> Kinda.
<jnthn> Hmm. I'm not sure off-hand why that doesn't work.
<masak> but it should, so it goes on the RT pile.
<jnthn> One of the annoyances of implementing callwith and nextwith is
that in the case of them being used to defer to another method, they
need to find and pass on the invocant.
<jnthn> Whereas in the case of a wrap, they maybe don't.
<masak> ah. tricky.
<jnthn> Yeah.
<jnthn> It'd not surprise me if we have bugs there.

Is this the desired behavior?

09​:39 < [Coke]> rakudo​: class A { has $.foo; method new($foo)
{nextwith(​:$foo)
  } }; say A.new("OH HAI").foo
09​:39 <+p6eval> rakudo 142c41​: OUTPUT«OH HAI␤»
09​:39 < [Coke]> rakudo​: class A { has $.foo; method new($foo) { say "ok"
} };
  say A.new("OH HAI")
09​:39 <+p6eval> rakudo 142c41​: OUTPUT«ok␤Bool​::True␤»
09​:39 < [Coke]> rakudo​: class A { has $.foo; method new($foo) {
callwith($foo)
  } }; say A.new("OH HAI").foo
09​:39 <+p6eval> rakudo 142c41​: OUTPUT«Default constructor only takes
named
  arguments␤ in method new at src/gen/CORE.setting​:516␤
in
  <anon> at src/gen/Metamodel.pm​:2375␤ in call_with_args
at
  src/gen/Metamodel.pm​:2372␤ in method new at
/tmp/WW9uUIODIh​:1␤
  in block <anon> at /tmp/WW9uUIODIh​:1␤ in <an…

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Oct 21, 2011

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

@p6rt
Copy link
Author

p6rt commented Oct 21, 2011

From @coke

09​:42 < masak> [Coke]​: looks like the desired behavior.

Closable with tests.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Oct 26, 2011

From @moritz

Now tested in S12-construction/new.t

@p6rt
Copy link
Author

p6rt commented Oct 26, 2011

@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