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

Incorrect Error Message for extra conditional keywords with unless/without #5863

Closed
p6rt opened this issue Dec 6, 2016 · 3 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 6, 2016

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

Searchable as RT130279$

@p6rt
Copy link
Author

p6rt commented Dec 6, 2016

From @zoffixznet

# I already have the fix; filing for records

If you try to write `else` with an `unless` clause, you get a nice error, telling you `unless` doesn't take `else` and you should rewrite with `if`

<ZoffixW> m​: unless 1 {} else {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while compiling <tmp>␤"unless" does not take "else", please rewrite using "if"␤at <tmp>​:1␤------> unless 1 {} ⏏else {}␤»

However, all other possible combination still talk about `unless` not taking `else` and suggest using `if`, even in cases where `if` would do a different thing​:

<ZoffixW> m​: unless 1 {} elsif {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while compiling <tmp>␤"unless" does not take "else", please rewrite using "if"␤at <tmp>​:1␤------> unless 1 {} ⏏elsif {}␤»
<ZoffixW> m​: unless 1 {} orwith {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while compiling <tmp>␤"unless" does not take "else", please rewrite using "if"␤at <tmp>​:1␤------> unless 1 {} ⏏orwith {}␤»
<ZoffixW> m​: without 1 {} else {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while compiling <tmp>␤"unless" does not take "else", please rewrite using "if"␤at <tmp>​:1␤------> without 1 {} ⏏else {}␤»
<ZoffixW> m​: without 1 {} elsif {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while compiling <tmp>␤"unless" does not take "else", please rewrite using "if"␤at <tmp>​:1␤------> without 1 {} ⏏elsif {}␤»
<ZoffixW> m​: without 1 {} orwith {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while compiling <tmp>␤"unless" does not take "else", please rewrite using "if"␤at <tmp>​:1␤------> without 1 {} ⏏orwith {}␤»

@p6rt
Copy link
Author

p6rt commented Dec 6, 2016

From @zoffixznet

On Tue, 06 Dec 2016 06​:34​:03 -0800, cpan@​zoffix.com wrote​:

# I already have the fix; filing for records

If you try to write `else` with an `unless` clause, you get a nice
error, telling you `unless` doesn't take `else` and you should rewrite
with `if`

<ZoffixW> m​: unless 1 {} else {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤"unless" does not take "else", please rewrite using
"if"␤at <tmp>​:1␤------> unless 1 {} ⏏else {}␤»

However, all other possible combination still talk about `unless` not
taking `else` and suggest using `if`, even in cases where `if` would
do a different thing​:

<ZoffixW> m​: unless 1 {} elsif {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤"unless" does not take "else", please rewrite using
"if"␤at <tmp>​:1␤------> unless 1 {} ⏏elsif {}␤»
<ZoffixW> m​: unless 1 {} orwith {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤"unless" does not take "else", please rewrite using
"if"␤at <tmp>​:1␤------> unless 1 {} ⏏orwith {}␤»
<ZoffixW> m​: without 1 {} else {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤"unless" does not take "else", please rewrite using
"if"␤at <tmp>​:1␤------> without 1 {} ⏏else {}␤»
<ZoffixW> m​: without 1 {} elsif {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤"unless" does not take "else", please rewrite using
"if"␤at <tmp>​:1␤------> without 1 {} ⏏elsif {}␤»
<ZoffixW> m​: without 1 {} orwith {}
<camelia> rakudo-moar 0ee6bc​: OUTPUT«===SORRY!=== Error while
compiling <tmp>␤"unless" does not take "else", please rewrite using
"if"␤at <tmp>​:1␤------> without 1 {} ⏏orwith {}␤»

Fixed in rakudo/rakudo@16fbd7147f
Tests in Raku/roast@d7328b7ca2

@p6rt
Copy link
Author

p6rt commented Dec 6, 2016

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

@p6rt p6rt closed this as completed Dec 6, 2016
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant