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

Redeclaration of return type in nested signature insufficiently forbidden in Rakudo #4511

Closed
p6rt opened this issue Sep 4, 2015 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 4, 2015

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

Searchable as RT125988$

@p6rt
Copy link
Author

p6rt commented Sep 4, 2015

From @masak

<masak_venue> m​: sub foo( Str &b​:(Bool --> Int) ) { say "alive" };
foo( sub (Bool) { 42 } )
<camelia> rakudo-moar e6f360​: OUTPUT«Type check failed in binding &b;
expected 'Callable[Str]' but got 'Sub'␤ in sub foo at
/tmp/fBPFLs3lWv​:1␤ in block <unit> at /tmp/fBPFLs3lWv​:1␤␤»
* masak_venue submits rakudobug
<jnthn> masak_venue​: Wait, why?
<masak_venue> (it ignores the inner/Int return type directive)
<jnthn> Oh...
<masak_venue> I think it should fail by forbidding doubly declaring it like that
<jnthn> Yeah, there's precedent for trying to catch such thinkos
<masak_venue> jnthn​: yes, lichtkind did it by mistake and didn't even realize.
<jnthn> m​: my Int foo() returns Str { }
<camelia> rakudo-moar e6f360​: OUTPUT«===SORRY!===␤Type 'Int' is not
declared. Did you mean 'int'?␤at /tmp/FG3lZlDRBh​:1␤------> my Int
⏏foo() returns Str { }␤Malformed my␤at /tmp/FG3lZlDRBh​:1␤------> my
Int ⏏foo() returns Str { }␤␤»
<masak_venue> it would be nice to catch it and throw the perfect error message
<jnthn> m​: my Int sub foo() returns Str { }
<camelia> rakudo-moar e6f360​: OUTPUT«===SORRY!=== Error while
compiling /tmp/RNk5jWh_lG␤Redeclaration of return type for foo
(previous return type was Int)␤at /tmp/RNk5jWh_lG​:1␤»
<jnthn> Something like that
<masak_venue> yes, that one

@p6rt
Copy link
Author

p6rt commented Nov 29, 2015

From @peschwa

On Fri Sep 04 09​:13​:10 2015, masak wrote​:

<masak_venue> m​: sub foo( Str &b​:(Bool --> Int) ) { say "alive" };
foo( sub (Bool) { 42 } )
<camelia> rakudo-moar e6f360​: OUTPUT«Type check failed in binding &b;
expected 'Callable[Str]' but got 'Sub'␤ in sub foo at
/tmp/fBPFLs3lWv​:1␤ in block <unit> at /tmp/fBPFLs3lWv​:1␤␤»
* masak_venue submits rakudobug
<jnthn> masak_venue​: Wait, why?
<masak_venue> (it ignores the inner/Int return type directive)
<jnthn> Oh...
<masak_venue> I think it should fail by forbidding doubly declaring it
like that
<jnthn> Yeah, there's precedent for trying to catch such thinkos
<masak_venue> jnthn​: yes, lichtkind did it by mistake and didn't even
realize.
<jnthn> m​: my Int foo() returns Str { }
<camelia> rakudo-moar e6f360​: OUTPUT«===SORRY!===␤Type 'Int' is not
declared. Did you mean 'int'?␤at /tmp/FG3lZlDRBh​:1␤------> my Int
⏏foo() returns Str { }␤Malformed my␤at /tmp/FG3lZlDRBh​:1␤------> my
Int ⏏foo() returns Str { }␤␤»
<masak_venue> it would be nice to catch it and throw the perfect error
message
<jnthn> m​: my Int sub foo() returns Str { }
<camelia> rakudo-moar e6f360​: OUTPUT«===SORRY!=== Error while
compiling /tmp/RNk5jWh_lG␤Redeclaration of return type for foo
(previous return type was Int)␤at /tmp/RNk5jWh_lG​:1␤»
<jnthn> Something like that
<masak_venue> yes, that one

As of Rakudo commit bb931c8fd this behaves as follows​:

10​:45 <psch> m​: sub f(Int &b​:(--> Str)) { }
10​:45 <camelia> rakudo-moar ff81e9​: OUTPUT«===SORRY!=== Error while compiling /tmp/Dv68JuR7Bq␤Redeclaration of return type for &b​:(--> Str)
  (previous return type was Int )␤at /tmp/Dv68JuR7Bq​:1␤------> sub f(Int &b​:(--> Str)⏏) { }␤»

This has been added as a test to roast in commit 6af57be0.

@p6rt
Copy link
Author

p6rt commented Nov 29, 2015

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

@p6rt
Copy link
Author

p6rt commented Nov 29, 2015

From @jnthn

On Sun Nov 29 02​:54​:14 2015, peschwa@​gmail.com wrote​:

On Fri Sep 04 09​:13​:10 2015, masak wrote​:

<masak_venue> m​: sub foo( Str &b​:(Bool --> Int) ) { say "alive" };
foo( sub (Bool) { 42 } )
<camelia> rakudo-moar e6f360​: OUTPUT«Type check failed in binding &b;
expected 'Callable[Str]' but got 'Sub'␤ in sub foo at
/tmp/fBPFLs3lWv​:1␤ in block <unit> at /tmp/fBPFLs3lWv​:1␤␤»
* masak_venue submits rakudobug
<jnthn> masak_venue​: Wait, why?
<masak_venue> (it ignores the inner/Int return type directive)
<jnthn> Oh...
<masak_venue> I think it should fail by forbidding doubly declaring
it
like that
<jnthn> Yeah, there's precedent for trying to catch such thinkos
<masak_venue> jnthn​: yes, lichtkind did it by mistake and didn't even
realize.
<jnthn> m​: my Int foo() returns Str { }
<camelia> rakudo-moar e6f360​: OUTPUT«===SORRY!===␤Type 'Int' is not
declared. Did you mean 'int'?␤at /tmp/FG3lZlDRBh​:1␤------> my Int
⏏foo() returns Str { }␤Malformed my␤at /tmp/FG3lZlDRBh​:1␤------> my
Int ⏏foo() returns Str { }␤␤»
<masak_venue> it would be nice to catch it and throw the perfect
error
message
<jnthn> m​: my Int sub foo() returns Str { }
<camelia> rakudo-moar e6f360​: OUTPUT«===SORRY!=== Error while
compiling /tmp/RNk5jWh_lG␤Redeclaration of return type for foo
(previous return type was Int)␤at /tmp/RNk5jWh_lG​:1␤»
<jnthn> Something like that
<masak_venue> yes, that one

As of Rakudo commit bb931c8fd this behaves as follows​:

10​:45 <psch> m​: sub f(Int &b​:(--> Str)) { }
10​:45 <camelia> rakudo-moar ff81e9​: OUTPUT«===SORRY!=== Error while
compiling /tmp/Dv68JuR7Bq␤Redeclaration of return type for &b​:(-->
Str)
(previous return type was Int )␤at
/tmp/Dv68JuR7Bq​:1␤------> sub f(Int &b​:(--> Str)⏏) { }␤»

This has been added as a test to roast in commit 6af57be0.

Which means we can resolve this issue. Thanks!

@p6rt p6rt closed this as completed Nov 29, 2015
@p6rt
Copy link
Author

p6rt commented Nov 29, 2015

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

@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