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

Junction as default value needs to throw if it would autothread #6670

Open
p6rt opened this issue Jan 31, 2018 · 4 comments
Open

Junction as default value needs to throw if it would autothread #6670

p6rt opened this issue Jan 31, 2018 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jan 31, 2018

Migrated from rt.perl.org#132794 (status was 'open')

Searchable as RT132794$

@p6rt
Copy link
Author

p6rt commented Jan 31, 2018

From @bbkr

$ perl6 -e 'sub MAIN ( $x = 1|2 ) { }'

Following oneliner will hang forever on Rakudo 2018.01.
Error exists for all type of Junctions.
Doesn't matter if they are built by infix "1|2" or by method "any(1,2)".

@p6rt
Copy link
Author

p6rt commented Jan 31, 2018

From @zoffixznet

On Wed, 31 Jan 2018 07​:26​:24 -0800, pawel.pabian@​getresponse.com wrote​:

$ perl6 -e 'sub MAIN ( $x = 1|2 ) { }'

Following oneliner will hang forever on Rakudo 2018.01.
Error exists for all type of Junctions.
Doesn't matter if they are built by infix "1|2" or by method "any(1,2)".

We can probably improve that behaviour with an error message (it applies to any routine, not just MAIN).

The problem is you're declaring an Any parameter, but your default value is a Junction, so when the default is used, it's trying to autothread the Junction and I'm guessing it keeps looping there in the guts somewhere.

Looking at your use, I'm suspecting you meant to use a `where` clause instead of the default value​:

  `perl6 -e 'sub MAIN ( $x where 1|2 ) { }'

@p6rt
Copy link
Author

p6rt commented Jan 31, 2018

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

@p6rt
Copy link
Author

p6rt commented Jan 31, 2018

From @zoffixznet

On Wed, 31 Jan 2018 07​:56​:31 -0800, cpan@​zoffix.com wrote​:

On Wed, 31 Jan 2018 07​:26​:24 -0800, pawel.pabian@​getresponse.com
wrote​:

$ perl6 -e 'sub MAIN ( $x = 1|2 ) { }'

Following oneliner will hang forever on Rakudo 2018.01.
Error exists for all type of Junctions.
Doesn't matter if they are built by infix "1|2" or by method
"any(1,2)".

We can probably improve that behaviour with an error message (it
applies to any routine, not just MAIN).

The problem is you're declaring an Any parameter, but your default
value is a Junction, so when the default is used, it's trying to
autothread the Junction and I'm guessing it keeps looping there in the
guts somewhere.

Looking at your use, I'm suspecting you meant to use a `where` clause
instead of the default value​:

`perl6 -e 'sub MAIN ( $x where 1|2 ) { }'

I started with this, but likely won't have time to finish it this week. In case someone else wants
to give it a go, some notes​:

1) jnthn++ agreed[^1] that this should throw
2) This code doesn't go through `check_param_default_type`[^2] in Actions. I tried passing the
  thunked[^3] defaults through the routine, but compilation fails
  with `Cannot unbox a type object (Str) to a str.`
3) The infiniloop is in the BOOTSTRAP[^4]. It basically keeps autothreading itself with no
  params over and over.

[1] https://irclog.perlgeek.de/perl6/2018-01-31#i_15761475
[2] https://github.com/rakudo/rakudo/blob/72948e8477fdb92801a59a6e101b29c2da2f844e/src/Perl6/Actions.nqp#L5050-L5058
[3] https://github.com/rakudo/rakudo/blob/72948e8477fdb92801a59a6e101b29c2da2f844e/src/Perl6/Actions.nqp#L5061
[4] https://github.com/rakudo/rakudo/blob/72948e8477fdb92801a59a6e101b29c2da2f844e/src/Perl6/Metamodel/BOOTSTRAP.nqp#L3336-L3362

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