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

Custom infix:<~~> multi not used by rakudo #4453

Closed
p6rt opened this issue Aug 3, 2015 · 13 comments
Closed

Custom infix:<~~> multi not used by rakudo #4453

p6rt opened this issue Aug 3, 2015 · 13 comments

Comments

@p6rt
Copy link

p6rt commented Aug 3, 2015

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

Searchable as RT125745$

@p6rt
Copy link
Author

p6rt commented Aug 3, 2015

From @ShimmerFairy

<ShimmerFairy> m​: class Foo { }; multi sub infix​:<>(Foo $a, Foo $b) { 42.6 }; say Foo.new ~~ Foo; say infix​:<>(Foo.new, Foo)
<camelia> rakudo-moar a38b59​: OUTPUT«True␤42.6␤»
<ShimmerFairy> (basically, the Perl 6 grammar treats ~~ specially, so stuff like this and the chaining bug pop up)

To explain, the ~~ infix is one of those operators that src/Perl6/Actions.pm treats specially, in this case constructing an AST for the expression with the 'make_smartmatch' method. The QAST generated by this method bypasses the infix and uses the ACCEPTS method on the arguments, meaning definitions of infix​:<> are never used for the operator. (It's potentially possible that the infix​:<> functions found in the core setting aren't used either.)

Bug #​81336 may also be caused by this special treatment, since the generated QAST (as mentioned) gives no consideration to any defined infix​:<~~> functions and shortcuts to calling ACCEPTS on the left-hand side.

@p6rt
Copy link
Author

p6rt commented Aug 4, 2015

From @moritz

Hi,

On 04.08.2015 00​:52, Faye (via RT) wrote​:

# New Ticket Created by Faye
# Please include the string​: [perl #​125745]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=125745 >

<ShimmerFairy> m​: class Foo { }; multi sub infix​:<>(Foo $a, Foo $b) { 42.6 }; say Foo.new ~~ Foo; say infix​:<>(Foo.new, Foo)
<camelia> rakudo-moar a38b59​: OUTPUT«True␤42.6␤»
<ShimmerFairy> (basically, the Perl 6 grammar treats ~~ specially, so stuff like this and the chaining bug pop up)

I'd argue that it's permissible to not consider custom infix​:<~~>,
because we already provide an avenue for customizing smart-match
behavior (method ACCEPTS of the RHS type).

Also note that the standard infix​:<~~> cannot be a normal operator,
because it topicalizes the RHS.

So, not a bug.

(But I cannot reject it in rt.perl.org right now because of login
problems; I hope I'll be able to do so later).

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Aug 4, 2015

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

@p6rt
Copy link
Author

p6rt commented Aug 4, 2015

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

@p6rt
Copy link
Author

p6rt commented Aug 4, 2015

From @labster

I'm actually going to reopen this one, because I think it needs the same treatment as #​125427 -- an error message that you're doing something which will never work. See commit 792578840.

On Mon Aug 03 23​:50​:07 2015, moritz wrote​:

Hi,

On 04.08.2015 00​:52, Faye (via RT) wrote​:

# New Ticket Created by Faye
# Please include the string​: [perl #​125745]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=125745 >

<ShimmerFairy> m​: class Foo { }; multi sub infix​:<>(Foo $a, Foo $b)
{ 42.6 }; say Foo.new ~~ Foo; say infix​:<
>(Foo.new, Foo)
<camelia> rakudo-moar a38b59​: OUTPUT«True␤42.6␤»
<ShimmerFairy> (basically, the Perl 6 grammar treats ~~ specially, so
stuff like this and the chaining bug pop up)

I'd argue that it's permissible to not consider custom infix​:<~~>,
because we already provide an avenue for customizing smart-match
behavior (method ACCEPTS of the RHS type).

Also note that the standard infix​:<~~> cannot be a normal operator,
because it topicalizes the RHS.

So, not a bug.

(But I cannot reject it in rt.perl.org right now because of login
problems; I hope I'll be able to do so later).

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Aug 4, 2015

@labster - Status changed from 'rejected' to 'open'

@p6rt
Copy link
Author

p6rt commented Aug 4, 2015

From @usev6

I created a PR for rakudo (following RT #​125427)​: rakudo/rakudo#487

$ perl6-m -e 'class Foo { }; multi sub infix​:<>(Foo $a, Foo $b) { 42.6 }; say Foo.new ~~ Foo; say infix​:<>(Foo.new, Foo)'
===SORRY!=== Error while compiling -e
Cannot override infix operator '', as it is a special form handled directly by the compiler
at -e​:1
------> class Foo { }; multi sub infix​:<
>⏏(Foo $a, Foo $b) { 42.6 }; say Foo.new ~

1 similar comment
@p6rt
Copy link
Author

p6rt commented Aug 4, 2015

From @usev6

I created a PR for rakudo (following RT #​125427)​: rakudo/rakudo#487

$ perl6-m -e 'class Foo { }; multi sub infix​:<>(Foo $a, Foo $b) { 42.6 }; say Foo.new ~~ Foo; say infix​:<>(Foo.new, Foo)'
===SORRY!=== Error while compiling -e
Cannot override infix operator '', as it is a special form handled directly by the compiler
at -e​:1
------> class Foo { }; multi sub infix​:<
>⏏(Foo $a, Foo $b) { 42.6 }; say Foo.new ~

@p6rt
Copy link
Author

p6rt commented Aug 4, 2015

From @lizmat

Merged.

On 04 Aug 2015, at 23​:16, Christian Bartolomaeus via RT <bugs-comment@​bugs6.perl.org> wrote​:

I created a PR for rakudo (following RT #​125427)​: rakudo/rakudo#487

$ perl6-m -e 'class Foo { }; multi sub infix​:<>(Foo $a, Foo $b) { 42.6 }; say Foo.new ~~ Foo; say infix​:<>(Foo.new, Foo)'
===SORRY!=== Error while compiling -e
Cannot override infix operator '', as it is a special form handled directly by the compiler
at -e​:1
------> class Foo { }; multi sub infix​:<
>⏏(Foo $a, Foo $b) { 42.6 }; say Foo.new ~

@p6rt
Copy link
Author

p6rt commented Aug 14, 2015

From @usev6

I added a test with commit d2d4f7a9.

In comments to PR 487 it was suggested to make the error message even better by mentioning .ACCEPTS (rakudo/rakudo#487 (comment)).

Should we leave the ticket open until someone does that or is the ticket closeable?

1 similar comment
@p6rt
Copy link
Author

p6rt commented Aug 14, 2015

From @usev6

I added a test with commit d2d4f7a9.

In comments to PR 487 it was suggested to make the error message even better by mentioning .ACCEPTS (rakudo/rakudo#487 (comment)).

Should we leave the ticket open until someone does that or is the ticket closeable?

@p6rt
Copy link
Author

p6rt commented Sep 7, 2015

From @jnthn

On Fri Aug 14 13​:30​:13 2015, bartolin@​gmx.de wrote​:

I added a test with commit d2d4f7a9.

In comments to PR 487 it was suggested to make the error message even
better by mentioning .ACCEPTS
(rakudo/rakudo#487 (comment)).

Should we leave the ticket open until someone does that or is the
ticket closeable?

Did the hint​:

$ perl6-m -e "class Foo { }; multi sub infix​:<>(Foo $a, Foo $b) { 42.6 }"
===SORRY!=== Error while compiling -e
Cannot override infix operator '
', as it is a special form handled directly by the compiler
(consider implementing an ACCEPTS method)
at -e​:1
------> class Foo { }; multi sub infix​:<~~><HERE>(Foo $a, Foo $b) { 42.6 }

So categorically closable now. :-)

@p6rt p6rt closed this as completed Sep 7, 2015
@p6rt
Copy link
Author

p6rt commented Sep 7, 2015

@jnthn - 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