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

Warning message for duplicated tighter trait #6661

Open
p6rt opened this issue Jan 12, 2018 · 3 comments
Open

Warning message for duplicated tighter trait #6661

p6rt opened this issue Jan 12, 2018 · 3 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Jan 12, 2018

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

Searchable as RT132710$

@p6rt
Copy link
Author

p6rt commented Jan 12, 2018

From @briandfoy

I was playing with higher orders of multiplication and defining some
operators for them. When I try to make one of my new operators tighter
than one I've already defined​:

  multi infix​:<↑> ( Int​:D $n, Int​:D $m --> Int​:D )
  is assoc<right>
  is tighter(&infix​:<**>)
  { $n ** $m }

  multi infix​:<↑↑> ( Int​:D $, 0 --> Int​:D )
  is assoc<right>
  is tighter(&infix​:<↑>)
  { 1 }

  multi infix​:<↑↑> ( Int​:D $n, Int​:D $m --> Int​:D )
  is assoc<right>
  is tighter(&infix​:<↑>)
  { [↑] $n xx $m }

  put 2 ↑ 3; # 2 * 2 * 2 = 8
  put 2 ↑↑ 3; # 2 ** 2 ** 2 = 16

This gets the odd error about something that's not part of my code​:

  ===SORRY!=== Error while compiling /Users/brian/Desktop/knuth2.p6.pl
  No such method 'subst' for invocant of type 'Any'

The problem turns out to be my duplication of the tighter. That's
better left to a proto definition instead of the candidates. I know
that now but the error message could have helped with that.

--
brian d foy <brian.d.foy@​gmail.com>
http://www.pair.com/~comdog/

@p6rt
Copy link
Author

p6rt commented Jan 14, 2018

From @zoffixznet

On Thu, 11 Jan 2018 20​:47​:48 -0800, comdog wrote​:

I was playing with higher orders of multiplication and defining some
operators for them. When I try to make one of my new operators tighter
than one I've already defined​:

multi infix&#8203;:\<↑> \( Int&#8203;:D $n, Int&#8203;:D $m  \-\-> Int&#8203;:D \)
    is assoc\<right>
    is tighter\(&infix&#8203;:\<\*\*>\)
    \{ $n \*\* $m \}

multi infix&#8203;:\<↑↑> \( Int&#8203;:D $, 0 \-\-> Int&#8203;:D \)
    is assoc\<right>
    is tighter\(&infix&#8203;:\<↑>\)
    \{ 1 \}

multi infix&#8203;:\<↑↑> \( Int&#8203;:D $n, Int&#8203;:D $m  \-\-> Int&#8203;:D \)
    is assoc\<right>
    is tighter\(&infix&#8203;:\<↑>\)
    \{ \[↑\] $n xx $m \}

put 2 ↑  3;  \# 2  \* 2  \* 2 =  8
put 2 ↑↑ 3;  \# 2 \*\* 2 \*\* 2 = 16

This gets the odd error about something that's not part of my code​:

===SORRY\!=== Error while compiling /Users/brian/Desktop/knuth2\.p6\.pl
No such method 'subst' for invocant of type 'Any'

The problem turns out to be my duplication of the tighter. That's
better left to a proto definition instead of the candidates. I know
that now but the error message could have helped with that.

I fixed the subst crash[^1][^2] and made it warn[^3][^4][^5] when duplicate
traits are used *on the same routine*.

When it came to making it warn for dupe use on more than one routine, I hit
a full can of bugs and giving up on this for now (if anyone wants to pick this
ticket up, go for it).

I drafted[^6] a warning system that tells the user to move traits to the proto
(or to the first multi, for implicit protos) as well as drafted[^7] all traits
changing configuration regardless of which multi they're applied to (doesn't
affect the parsing though but affects the config values themselves globally).
Both ideas are crap and don't quite work out.

Unsure which way to go here.

There's a grammar bug[^8], where we don't change precedence of ops, even if
we completely shadow them. However, if that's fixed, I believe we'll still have
this weird case where a setup like this (O = Op multi candidates; P = Precedence)​:

  O1-P1; { O2-P2; }

Would have a language that parses `O` with precedence and associativity of `P2`
inside the block, yet both `O1` and `O2` candidates would be available when calling
that op.

Currently, there's also bug where trying to apply tighter/looser more than once
messes up the configuration (it replaces `=` to `​:=`, but if it's already `​:=` it
replaces it to `​::=`).

[1] rakudo/rakudo@029226f
[2] Raku/roast@27f9e2e
[3] rakudo/rakudo@ad60b94
[4] rakudo/rakudo@732a25c
[5] Raku/roast@2dca47b
[6] rakudo/rakudo@6b17ab1
[7] rakudo/rakudo@29a6182
[8] rakudo/rakudo#1237

@p6rt
Copy link
Author

p6rt commented Jan 14, 2018

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

@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant