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

Confusing parsing (and spec?) for my A $a .= new.foo #2861

Closed
p6rt opened this issue Aug 12, 2012 · 4 comments
Closed

Confusing parsing (and spec?) for my A $a .= new.foo #2861

p6rt opened this issue Aug 12, 2012 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Aug 12, 2012

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

Searchable as RT114464$

@p6rt
Copy link
Author

p6rt commented Aug 12, 2012

From @softmoth

Rakudo behaves differently to Niecza and Pugs here​:

14​:30 <thou> nrp​: class A { method foo() { say "Foo!"; return self; };
method bar() { say "Bar." }}; my A $a .= new.foo; $a.bar;
14​:30 <p6eval> rakudo e20252​: OUTPUT«===SORRY!===␤Confused␤at
/tmp/TKFTMXpqZJ​:1␤»
14​:30 <p6eval> ..niecza v19-20-g07dcc9e, pugs​: OUTPUT«Foo!␤Bar.␤»

I expected it to behave the same as​:

14​:30 <thou> nrp​: class A { method foo() { say "Foo!"; return self; };
method bar() { say "Bar." }}; my A $a = A.new.foo; $a.bar;
14​:30 <p6eval> rakudo e20252, niecza v19-20-g07dcc9e, pugs​: OUTPUT«Foo!␤Bar.␤»

jnthn seems to disagree​:

14​:20 <thou> prn​: class A { method foo() { say "Foo!"; }}; my A $a .= new.foo;
14​:20 <p6eval> niecza v19-20-g07dcc9e​: OUTPUT«Potential difficulties​:␤
$a is declared but not used at /tmp/J0sWSYjJij line 1​:␤------> [32mA
{ method foo() { say "Foo!"; }}; my A [33m⏏ [31m$a .=
new.foo; [0m␤␤Foo!␤»
14​:20 <p6eval> ..rakudo e20252​: OUTPUT«===SORRY!===␤Confused␤at
/tmp/7x7OEuUesF​:1␤»
14​:20 <p6eval> ..pugs​: OUTPUT«Foo!␤»
14​:20 <thou> ^ rakudobug?
14​:21 <jnthn> On on earth is that parsed?
14​:21 <jnthn> std​: class A { method foo() { say "Foo!"; }}; my A $a .= new.foo;
14​:21 <p6eval> std d96f25c​: OUTPUT«ok 00​:00 43m␤»
14​:22 <jnthn> I'm wondering if it parses as
14​:22 <jnthn> (class A { method foo() { say "Foo!"; }}; my A $a .= new).foo
14​:22 <jnthn> n​: class A { method foo() { say "Foo!"; }}; say (my A $a
.= new.foo);
14​:22 <p6eval> niecza v19-20-g07dcc9e​: OUTPUT«Potential difficulties​:␤
$a is declared but not used at /tmp/NsCAi8hNTx line 1​:␤------>
[32method foo() { say "Foo!"; }}; say (my A [33m⏏ [31m$a .=
new.foo); [0m␤␤Foo!␤True␤»
14​:22 <jnthn> n​: class A { method foo() { say "Foo!"; }}; my A $a .=
new.foo; say $a
14​:22 <p6eval> niecza v19-20-g07dcc9e​: OUTPUT«Foo!␤A.new(...)␤»
14​:23 <jnthn> Yeah
14​:23 <thou> prn​: class A { method foo() { say "Foo!"; }}; my A $a .= new().foo;
14​:23 <p6eval> rakudo e20252​: OUTPUT«===SORRY!===␤Confused␤at
/tmp/fc3hH_uQrn​:1␤»
14​:23 <p6eval> ..pugs​: OUTPUT«Foo!␤»
14​:23 <p6eval> ..niecza v19-20-g07dcc9e​: OUTPUT«Potential
difficulties​:␤ $a is declared but not used at /tmp/V6GAlCpxVn line
1​:␤------> [32mA { method foo() { say "Foo!"; }}; my A [33m⏏ [31m$a
.= new().foo; [0m␤␤Foo!␤»
14​:23 <masak> std​: class A { method foo() { say "Foo!"; }}; my A $a .= new.foo
14​:23 <p6eval> std d96f25c​: OUTPUT«ok 00​:00 43m␤»
14​:23 <jnthn> or...something else...huh :)
14​:25 <thou> jnthn, i was looking for a way to avoid writing​: my A $a
= A.new.foo;
14​:26 <jnthn> thou​: That isn't what the code you wrote is doing.
14​:26 <masak> thou​: I think the '.= new.foo' syntax should either be
disallowed, or mean 'A $a = A.new.foo'.

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

From @TimToady

This works now, due to the precedence changes associated with adding the dot infix operator.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

From @TimToady

This works now, due to the precedence changes associated with adding the dot infix operator.

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

@TimToady - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed Oct 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant