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

Can't set rx{} as parameter default #4428

Closed
p6rt opened this issue Jul 24, 2015 · 4 comments
Closed

Can't set rx{} as parameter default #4428

p6rt opened this issue Jul 24, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jul 24, 2015

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

Searchable as RT125670$

@p6rt
Copy link
Author

p6rt commented Jul 24, 2015

From @japhb

It appears you can't use an rx{} literal as a parameter default​:

$ perl6 -e 'sub foo($r) { say $r }; foo(rx{bar});'
rx{bar}
$ perl6 -e 'sub foo($r = rx{foo}) { say $r }; foo(rx{bar});'
===SORRY!===
Cannot call method 'match' on a null object
$ perl6 -v
This is perl6 version 2015.06-314-g5d1ec3c built on MoarVM version
2015.06-98-gf22142b

This is golfed down from a bug causing flussence's Text-Tabs-Wrap
module Text​::Wrap to no longer compile, throwing the above SORRY!
error right when it tries to parse the params to sub wrap().

Interestingly there appears to be a funky workaround​:

$ perl6 -e 'sub foo($r = {rx{foo}}()) { say $r }; foo(rx{bar}); foo();'
rx{bar}
rx{foo}

@p6rt
Copy link
Author

p6rt commented Jul 30, 2015

From @jnthn

On Thu Jul 23 19​:11​:18 2015, gjb@​google.com wrote​:

It appears you can't use an rx{} literal as a parameter default​:

$ perl6 -e 'sub foo($r) { say $r }; foo(rx{bar});'
rx{bar}
$ perl6 -e 'sub foo($r = rx{foo}) { say $r }; foo(rx{bar});'
===SORRY!===
Cannot call method 'match' on a null object
$ perl6 -v
This is perl6 version 2015.06-314-g5d1ec3c built on MoarVM version
2015.06-98-gf22142b

This is golfed down from a bug causing flussence's Text-Tabs-Wrap
module Text​::Wrap to no longer compile, throwing the above SORRY!
error right when it tries to parse the params to sub wrap().

Interestingly there appears to be a funky workaround​:

$ perl6 -e 'sub foo($r = {rx{foo}}()) { say $r }; foo(rx{bar}); foo();'
rx{bar}
rx{foo}

Turned out to be a funky "static analysis gone wild" bug. Fixed, added test in S06-signature/defaults.t.

@p6rt
Copy link
Author

p6rt commented Jul 30, 2015

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

@p6rt
Copy link
Author

p6rt commented Jul 30, 2015

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

@p6rt p6rt closed this as completed Jul 30, 2015
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