[perl #132794] Junction as default value of MAIN param hangs forever

[email protected] ("Zoffix Znet via RT")
Newsgroups perl.perl6.compiler
Message-ID <[email protected]>
On Wed, 31 Jan 2018 07:56:31 -0800, [email protected] wrote:
> On Wed, 31 Jan 2018 07:26:24 -0800, [email protected]
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.