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

Error missing declared signature if where clause is used in proto #1746

Open
zoffixznet opened this issue Apr 18, 2018 · 6 comments
Open

Error missing declared signature if where clause is used in proto #1746

zoffixznet opened this issue Apr 18, 2018 · 6 comments
Labels
dispatching Routine dispatching easy to resolve This issue is likely easy for beginners to resolve good first issue This issue is likely easy for beginners to resolve Hacktoberfest Issues for Hacktoberfest event LTA Less Than Awesome; typically an error message that could be better

Comments

@zoffixznet
Copy link
Contributor

zoffixznet commented Apr 18, 2018

See Newcomer Guide to Contributing to Core Perl 6 for tips on fixing this Issue


Normally, this message tells you what the declared signature is (in this case, (Int)):

$ perl6 -e 'sub z(Int) {}; z "x"'
===SORRY!=== Error while compiling -e
Calling z(Str) will never work with declared signature (Int)

But if you use a where clause and stick it into proto, the with declared signature part doesn't say what the declared signature is:

19:39 	Zoffix 	m: proto z($ where rand) {*}; say z "x"
19:39 	camelia 	rakudo-moar 9e6ae276a: OUTPUT: «5===SORRY!5=== Error while compiling <tmp>␤Calling z(Str) will never work with declared signature ␤at <tmp>:1␤------> 3proto z($ where rand) {*}; say 7⏏5z "x"␤»
@zoffixznet zoffixznet added good first issue This issue is likely easy for beginners to resolve LTA Less Than Awesome; typically an error message that could be better labels Apr 18, 2018
@jsimonet
Copy link
Contributor

jsimonet commented May 2, 2018

The absence of signature comes from the fact that only multi signatures are shown (https://github.com/rakudo/rakudo/blob/master/src/Perl6/Optimizer.nqp#L2178).

But the error seems to be related with the fact we are trying to call a dispatcher proto which does not have multis:

$ perl6 -e 'proto z() {*}; say z'
===SORRY!=== Error while compiling -e
Calling z() will never work with declared signature 
at -e:1

$ perl6 -e 'proto z() {}; say z'
Nil

perl6 -e 'proto z() {*}; multi z() {}; say z'    
Nil

@jsimonet
Copy link
Contributor

jsimonet commented May 2, 2018

In addition, using a where clause causes the signatures to be evaluated at runtime. If a multi is specified, the error is a TypeCheck Exception.

perl6 --stagestats -e 'proto z( $ where rand ) {*}; multi z($ where rand){}; say z "x"'
Stage start      :   0.000
Stage parse      :   0.147
Stage syntaxcheck:   0.000
Stage ast        :   0.000
Stage optimize   :   0.004
Stage mast       :   0.009
Stage mbc        :   0.000
Stage moar       :   0.000
Constraint type check failed in binding to parameter '<anon>'; expected anonymous constraint to be met but got Str ("x")
  in block <unit> at -e line 1

@zoffixznet zoffixznet added the easy to resolve This issue is likely easy for beginners to resolve label May 14, 2018
@jsimonet
Copy link
Contributor

Tried to implement a fix in PR #1868

@dolmen
Copy link

dolmen commented Aug 10, 2018

This looks fixed in rakudo star 2018.06:

$ perl6 -e 'proto z($ where rand) {*}; say z "x"'
===SORRY!=== Error while compiling -e
Calling z(Str) will never work with declared signature
at -e:1
------> proto z($ where rand) {*}; say ⏏z "x"

@zoffixznet
Copy link
Contributor Author

Tried to implement a fix in PR #1868

Commented on the PR.

This looks fixed in rakudo star 2018.06:

That's still missing what the declared signature is.

@tinmarino
Copy link
Contributor

I made PR #3558 creating a new Exception class. Then realized that #1868 handled it better. But got Blocked.
How to unblock it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dispatching Routine dispatching easy to resolve This issue is likely easy for beginners to resolve good first issue This issue is likely easy for beginners to resolve Hacktoberfest Issues for Hacktoberfest event LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants