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

CHECK/INIT return inside a sub causes incorrect (?) error and segv respectively #6088

Closed
p6rt opened this issue Feb 21, 2017 · 5 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Feb 21, 2017

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

Searchable as RT130825$

@p6rt
Copy link
Author

p6rt commented Feb 21, 2017

From @zoffixznet

00​:27 IOninja m​: sub {CHECK return; class :​: { 5000; 42 } }()
00​:27 camelia rakudo-moar 80e0bc​: OUTPUT​: «===SORRY!===␤Attempt to return outside of any Routine␤»
00​:27 IOninja m​: sub {INIT return; class :​: { 5000; 42 } }()
00​:27 camelia rakudo-moar 80e0bc​: OUTPUT​: «(signal SEGV)WARNINGS for <tmp>​:␤Useless use of constant integer 42 in sink context (line 1)␤Useless use of constant integer 5000 in sink context (line 1)␤»

@p6rt
Copy link
Author

p6rt commented Feb 21, 2017

@p6rt
Copy link
Author

p6rt commented Feb 22, 2017

From @jnthn

On Mon, 20 Feb 2017 16​:28​:54 -0800, cpan@​zoffix.com wrote​:

00​:27 IOninja m​: sub {CHECK return; class :​: { 5000; 42 } }()
00​:27 camelia rakudo-moar 80e0bc​: OUTPUT​: «===SORRY!===␤Attempt to
return outside of any Routine␤»

This one has been corrected to report that the problem was in a CHECK block and to include a line number (same kind of reporting already in place for BEGIN blocks and other compile-time evaluations; CHECK somehow got left out).

$ ./perl6-m -e 'sub {CHECK return;}'===SORRY!=== Error while compiling -e
An exception occurred while evaluating a CHECK
at -e​:1
Exception details​:
  Attempt to return outside of any Routine
  in code at -e line 1

00​:27 IOninja m​: sub {INIT return; class :​: { 5000; 42 } }()
00​:27 camelia rakudo-moar 80e0bc​: OUTPUT​: «(signal SEGV)WARNINGS for
<tmp>​:␤Useless use of constant integer 42 in sink context (line
1)␤Useless use of constant integer 5000 in sink context (line 1)␤»

This one no longer SEGVs, and instead complains about the return​:

$ ./perl6-m -e 'sub {INIT return; class :​: { 5000; 42 } }()'
WARNINGS for -e​:
Useless use of constant integer 42 in sink context (line 1)
Useless use of constant integer 5000 in sink context (line 1)
Attempt to return outside of any Routine
  in block <unit> at -e line 1

Tests added to S04-statements/return.t.

@p6rt
Copy link
Author

p6rt commented Feb 22, 2017

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

@p6rt
Copy link
Author

p6rt commented Feb 22, 2017

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

@p6rt p6rt closed this as completed Feb 22, 2017
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