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

LTA error for bad multi method calls at compile time #3711

Closed
p6rt opened this issue Mar 2, 2015 · 5 comments
Closed

LTA error for bad multi method calls at compile time #3711

p6rt opened this issue Mar 2, 2015 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Mar 2, 2015

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

Searchable as RT123967$

@p6rt
Copy link
Author

p6rt commented Mar 2, 2015

From @drforr

OS​: Ubuntu 14.10 Linux 64-bit, 2GiB RAM, VirtualBox
Host​: Windows 8 Intel i5 Core

rakudo commit 67a75c1e1d9ed99326b7e426eea3cd969dba35ea
Date​: Sat Feb 28 16​:16​:52 2015 +0100

Accidentally called $class.new(...) without a matching signature. The
compiler correctly reports that it could not find a matching signature,
but incorrectly does *not* report the package/file/line where the bad
call occurred. Incidentally, the signature it *did* try has a trailing
'*%_' that doesn't occur in the actual code, but that may be a compiler
artifact.

The entirety of the error is​:

--cut here--
===SORRY!===
Cannot call 'new'; none of these signatures match​:
:(Polar $​: Real \mag, Real \theta, *%_)
--cut here--

Below is the class, followed by the admittedly incorrect attempt to
invoke it​:

--cut here--
class Polar {
  proto method new(|) { * }
  multi method new(Real \mag, Real \theta) { }
}

constant j = Polar.new( 0e0 );

say j.re;
--cut here--

@p6rt
Copy link
Author

p6rt commented Mar 4, 2015

From @Mouq

FWIW the *%_ is correct. I'm marking this LTA error as dependent upon #​114204, since that ticket covers the lack of Capture information in the error.

On another note, changing `constant j` to `my \term​:<j>` or `my $j` restores the line numbers to the error. This gives a clue, since the RHS of constants are evaluated at compile time. And indeed, that seems to be the culprit for the missing line numbers​:

$ perl6 -e'class Polar {proto method new (|) {*}; multi method new(Real \mag, Real \theta) { }}; Polar.new(1e0)'
Cannot call 'new'; none of these signatures match​:
:(Polar $​: Real \mag, Real \theta, *%_)
  in block <unit> at -e​:1

$ perl6 -e'class Polar {proto method new (|) {*}; multi method new(Real \mag, Real \theta) { }}; BEGIN Polar.new(1e0)'
===SORRY!===
Cannot call 'new'; none of these signatures match​:
:(Polar $​: Real \mag, Real \theta, *%_)
$ perl6 -e'class Polar {proto method new (|) {*}; multi method new(Real \mag, Real \theta) { }}; CHECK Polar.new(1e0)'
===SORRY!===
Cannot call 'new'; none of these signatures match​:
:(Polar $​: Real \mag, Real \theta, *%_)

I found ticket #​81502 which covers this error, and am adding that as another dependency for this bug.

I have no problem if someone wants to close this as being a duplicate. The two dependencies seem to cover the problem, although this ticket/use case may still be useful to have :)

On Mon Mar 02 12​:41​:03 2015, drforr@​pobox.com wrote​:

OS​: Ubuntu 14.10 Linux 64-bit, 2GiB RAM, VirtualBox
Host​: Windows 8 Intel i5 Core

rakudo commit 67a75c1e1d9ed99326b7e426eea3cd969dba35ea
Date​: Sat Feb 28 16​:16​:52 2015 +0100

Accidentally called $class.new(...) without a matching signature. The
compiler correctly reports that it could not find a matching signature,
but incorrectly does *not* report the package/file/line where the bad
call occurred. Incidentally, the signature it *did* try has a trailing
'*%_' that doesn't occur in the actual code, but that may be a compiler
artifact.

The entirety of the error is​:

--cut here--
===SORRY!===
Cannot call 'new'; none of these signatures match​:
:(Polar $​: Real \mag, Real \theta, *%_)
--cut here--

Below is the class, followed by the admittedly incorrect attempt to
invoke it​:

--cut here--
class Polar {
proto method new(|) { * }
multi method new(Real \mag, Real \theta) { }
}

constant j = Polar.new( 0e0 );

say j.re;
--cut here--

@p6rt
Copy link
Author

p6rt commented Mar 4, 2015

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

@p6rt
Copy link
Author

p6rt commented Apr 8, 2015

From @jnthn

On Mon Mar 02 12​:41​:03 2015, drforr@​pobox.com wrote​:

Accidentally called $class.new(...) without a matching signature. The
compiler correctly reports that it could not find a matching signature,
but incorrectly does *not* report the package/file/line where the bad
call occurred. Incidentally, the signature it *did* try has a trailing
'*%_' that doesn't occur in the actual code, but that may be a compiler
artifact.

The entirety of the error is​:

--cut here--
===SORRY!===
Cannot call 'new'; none of these signatures match​:
:(Polar $​: Real \mag, Real \theta, *%_)
--cut here--

Below is the class, followed by the admittedly incorrect attempt to
invoke it​:

--cut here--
class Polar {
proto method new(|) { * }
multi method new(Real \mag, Real \theta) { }
}

constant j = Polar.new( 0e0 );

say j.re;
--cut here--

It now reports rather more information about what went wrong;

===SORRY!=== Error while compiling z.p6
An exception occurred while evaluating a constant
at z.p6​:6
Exception details​:
  Cannot call new(Polar​: Num); none of these signatures match​:
  (Polar​: Real \mag, Real \theta, *%_)
  in any new at src/Perl6/World.nqp​:1313
  in block at z.p6​:6

Test added in S32-exceptions/misc.t.

@p6rt p6rt closed this as completed Apr 8, 2015
@p6rt
Copy link
Author

p6rt commented Apr 8, 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant