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 message when no multi method candidate can be invoked #1856

Closed
p6rt opened this issue Jun 19, 2010 · 5 comments
Closed

LTA error message when no multi method candidate can be invoked #1856

p6rt opened this issue Jun 19, 2010 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Jun 19, 2010

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

Searchable as RT75872$

@p6rt
Copy link
Author

p6rt commented Jun 19, 2010

From @moritz

12​:11 <@​moritz_> rakudo​: class A { multi method b($x where { 0 } ) { }
}; A.new.b(4)
12​:11 <+p6eval> rakudo 92e914​: OUTPUT«No candidates found to invoke␤ in
main program body at line 11​:/tmp/jdOpy6exrT␤»
12​:13 * moritz_ submits rakudobug about LTA error message

It should mention at least​:
1) the name of the method
2) the type of the invocant

bonus points (and a beer at our next meeting) for listing candidates
like failed multi sub dispatch does it.

@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

From @jnthn

On Sat Jun 19 03​:15​:52 2010, moritz wrote​:

12​:11 <@​moritz_> rakudo​: class A { multi method b($x where { 0 } ) { }
}; A.new.b(4)
12​:11 <+p6eval> rakudo 92e914​: OUTPUT«No candidates found to invoke␤ in
main program body at line 11​:/tmp/jdOpy6exrT␤»
12​:13 * moritz_ submits rakudobug about LTA error message

It should mention at least​:
1) the name of the method
2) the type of the invocant

bonus points (and a beer at our next meeting) for listing candidates
like failed multi sub dispatch does it.

So, taking a more interesting example​:

class A {
  multi method b($x) { 1 }
  multi method b($x, $y) { 2 }
}
say A.new.b();

Running this now gives the far, far more informative​:

No candidates found to invoke for method 'b' on object of type 'A';
available candidates have signatures​:
:(Mu : Any $x;; *%_)
:(Mu : Any $x, Any $y;; *%_)
  in main program body at line 5​:test.p6

Good enough for beer? ;-)

Given to moritz++ in case this is something that is testable or should
be tested.

Jonathan

@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

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

@p6rt
Copy link
Author

p6rt commented Jul 18, 2010

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

@p6rt p6rt closed this as completed Jul 18, 2010
@p6rt
Copy link
Author

p6rt commented Jul 18, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S12-methods/multi.t

commit 4b312a5186e94c35751ac9e57bd520cd5869ad49
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sun Jul 18 12​:17​:21 2010 +0000

  [t/spec] tests for RT #​75872, awesome error message when multi method dispatch finds no matching candidate
 
  Moritz ows jnthn++ a beer.
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31746 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S12-methods/multi.t b/t/spec/S12-methods/multi.t
index 08e753f..5710b21 100644
--- a/t/spec/S12-methods/multi.t
+++ b/t/spec/S12-methods/multi.t
@@ -194,6 +194,16 @@ is Bar.new.a("not an Int"), 'Any-method in Foo';
 
     is WorkingTie.has_tie( 42 ), 'tie3', 'broken class fixed by subclass (1)';
     is WorkingTie.has_tie( 'x' ), 'tie4', 'broken class fixed by subclass (2)';
+
+    my $error;
+    try {
+        WorkingTie.new.has_tie([]);
+    }
+    $error = "$!";
+    ok $error ~~ /<< 'has_tie' >>/,
+        'error message for failed dispatch contains method name';
+    ok $error ~~ /<< 'WorkingTie' >>/,
+        'error message for failed dispatch contains invocant type';
 }
 
 done_testing;

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