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

Using True in a sub signature makes no sense but there is no warning (sub foo(True) {}) #5824

Closed
p6rt opened this issue Nov 26, 2016 · 4 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Nov 26, 2016

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

Searchable as RT130182$

@p6rt
Copy link
Author

p6rt commented Nov 26, 2016

From @AlexDaniel

*Code​:*
sub foo(True) { say ‘ok’ };
foo(False)

*Result​:*
ok

The reason for it is the following​:

*Code​:*
42 ~~ True

*Result​:*
Potential difficulties​:
  Smartmatch against True always matches; if you mean to test the topic
for truthiness, use :so or *.so or ?* instead
  at -e​:1
  ------> 42 ~~ ⏏True

So it is not a bug by itself, it's just how smartmatching works. But we
should definitely print a warning there (or maybe even a compile-time
error?).

IRC log​: https://irclog.perlgeek.de/perl6/2016-11-26#i_13632723 and
specifically https://irclog.perlgeek.de/perl6/2016-11-26#i_13632798

@p6rt
Copy link
Author

p6rt commented Dec 26, 2016

From @zoffixznet

On Sat, 26 Nov 2016 13​:19​:50 -0800, alex.jakimenko@​gmail.com wrote​:

*Code​:*
sub foo(True) { say ‘ok’ };
foo(False)

*Result​:*
ok

The reason for it is the following​:

*Code​:*
42 ~~ True

*Result​:*
Potential difficulties​:
Smartmatch against True always matches; if you mean to test the topic
for truthiness, use :so or *.so or ?* instead
at -e​:1
------> 42 ~~ ⏏True

So it is not a bug by itself, it's just how smartmatching works. But we
should definitely print a warning there (or maybe even a compile-time
error?).

IRC log​: https://irclog.perlgeek.de/perl6/2016-11-26#i_13632723 and
specifically https://irclog.perlgeek.de/perl6/2016-11-26#i_13632798

Thank you for the report. This is now fixed.

Fix​: rakudo/rakudo@b01dfcda90
Tests​: Raku/roast@7095892afe

@p6rt
Copy link
Author

p6rt commented Dec 26, 2016

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

@p6rt
Copy link
Author

p6rt commented Dec 26, 2016

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

@p6rt p6rt closed this as completed Dec 26, 2016
@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