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

:{ } sometimes constructs a Block #1559

Open
zoffixznet opened this issue Feb 23, 2018 · 1 comment
Open

:{ } sometimes constructs a Block #1559

zoffixznet opened this issue Feb 23, 2018 · 1 comment

Comments

@zoffixznet
Copy link
Contributor

Seems to me there's no ambiguity between object hash and Block constructor and so you should always get a Hash or syntax/odd-number-of-items errors instead:

https://irclog.perlgeek.de/perl6-dev/2018-02-23#i_15851491

18:48 	Zoffix 	m: dd :{:$_}
18:48 	camelia 	rakudo-moar 6006e2f63: OUTPUT: «-> ;; $_? is raw { #`(Block|59930128) ... }␤»
18:48 	Zoffix 	This is a bug, innit? That shouldn't ever be a Block
18:48 		m: dd :{;}
18:48 	camelia 	rakudo-moar 6006e2f63: OUTPUT: «-> ;; $_? is raw { #`(Block|63574576) ... }␤»

TimToady 	looks kinda like a bug to me; the $_ criterion was only supposed to be for disambiguating bare {} in cases where it's obviously intened as a block, like in: map { $_ => 1 }, ...
zoffixznet added a commit to Raku/doc that referenced this issue Feb 23, 2018
- :{} making Blocks is a bug. Now filed as R#1559
     rakudo/rakudo#1559
- There *are* actually two ways to make object hashes
   without :{}, so show them.
@kjkuan
Copy link

kjkuan commented Nov 24, 2019

I happened to discover this bug last night and exploited it for my purpose:

multi sub val(Block:D $c, :$val-or-fail) { $c().flat>>.Str.Slip }

my @a = << arg2 "arg 3" >>;
dd <<arg1 :{@a} arg4>>;  # ("arg1", "arg2", "arg 3", "arg4")

The idea is to have something similar to how "${array[@]}" is expanded in Bash, which seems to be impossible without this bug + the above hack...

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

2 participants