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

wrong error messages #3697

Closed
p6rt opened this issue Feb 21, 2015 · 4 comments
Closed

wrong error messages #3697

p6rt opened this issue Feb 21, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Feb 21, 2015

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

Searchable as RT123897$

@p6rt
Copy link
Author

p6rt commented Feb 21, 2015

From @MARTIMM

In the piece of code shown below perl6 generates a wrong message. In the
original code there were more multi methods but could bring it down to one.

#!/usr/bin/env perl6
#
use v6;
use BSON​::Javascript;

class C {
  multi method c1 ( BSON​::Javascript $js1,
  BSON​::Javascript :$js2 = ''
  ) {
  }
}

my C $ic .= new();
my BSON​::Javascript $bjs .= new(javascript => 'function(){}');
$ic.c1($bjs);

The error generated is;

Cannot call 'c1'; none of these signatures match​:
:(C $​: BSON​::Javascript $js1, BSON​::Javascript :js2($js2) = { ... }, *%_)
  in block <unit> at i.pl6​:17

This message leads you to investigating the call to the method which is
wrong. When the 'multi' is removed from the method, the real problem
gets revealed;

Type check failed in binding $js2; expected 'BSON​::Javascript' but got 'Str'
  in method c1 at i.pl6​:7
  in block <unit> at i.pl6​:17

The used Perl version is;
This is perl6 version 2015.01-77-gd320f00 built on MoarVM version
2015.01-21-g4ee4925

Greetings,
Marcel Timmerman
@​MARTIMM on github

@p6rt
Copy link
Author

p6rt commented Jun 30, 2015

From @jnthn

On Sat Feb 21 07​:33​:27 2015, mt1957@​gmail.com wrote​:

In the piece of code shown below perl6 generates a wrong message. In the
original code there were more multi methods but could bring it down to one.

#!/usr/bin/env perl6
#
use v6;
use BSON​::Javascript;

class C {
multi method c1 ( BSON​::Javascript $js1,
BSON​::Javascript :$js2 = ''
) {
}
}

my C $ic .= new();
my BSON​::Javascript $bjs .= new(javascript => 'function(){}');
$ic.c1($bjs);

The error generated is;

Cannot call 'c1'; none of these signatures match​:
:(C $​: BSON​::Javascript $js1, BSON​::Javascript :js2($js2) = { ... }, *%_)
in block <unit> at i.pl6​:17

This message leads you to investigating the call to the method which is
wrong. When the 'multi' is removed from the method, the real problem
gets revealed;

Type check failed in binding $js2; expected 'BSON​::Javascript' but got 'Str'
in method c1 at i.pl6​:7
in block <unit> at i.pl6​:17

The used Perl version is;
This is perl6 version 2015.01-77-gd320f00 built on MoarVM version
2015.01-21-g4ee4925

We now actually go so far as to catch this one at compile time. So, a golfed version of the script submitted​:

class BSON​::Javascript { }
class C {
  multi method c1 ( BSON​::Javascript $js1,
  BSON​::Javascript :$js2 = ''
  ) {
  }
}

Now fails to compile with​:

===SORRY!=== Error while compiling bug3.p6
Default value '' will never bind to a parameter of type BSON​::Javascript
at bug3.p6​:2
------> multi c1 (BSON​::Javascript :$js2 = ''<HERE>) { }

Added a regression test in S06-signature/optional.t.

@p6rt
Copy link
Author

p6rt commented Jun 30, 2015

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

@p6rt p6rt closed this as completed Jun 30, 2015
@p6rt
Copy link
Author

p6rt commented Jun 30, 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