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
Rakudo can't autovivify arrays from hash items via push() #2025
Comments
From @moritz07:45 < moritz_> rakudo: my %h; push %h<a>, 1, 2; say %h.perl |
From @TimbusThe issue isn't with hashes, it's with the Any that is returned when you This patch seems to comply. And if push is meant to vivify an Array |
From @Timbuspushfix.patchdiff --git a/src/core/Any-list.pm b/src/core/Any-list.pm
index f61784e..6e4175f 100644
--- a/src/core/Any-list.pm
+++ b/src/core/Any-list.pm
@@ -26,6 +26,11 @@ augment class Any {
~pir::join__SsP($separator, self.flat.eager);
}
+ our multi method push (*@items) is export {
+ if self //= List.new() { nextsame }
+ else { self.push(@items) }
+ }
+
multi method elems() {
1;
}
diff --git a/src/core/List.pm b/src/core/List.pm
index ea699d7..a8753a4 100644
--- a/src/core/List.pm
+++ b/src/core/List.pm
@@ -80,7 +80,7 @@ augment class List does Positional {
!! fail('Undefined value popped from empty array');
}
- our method push(*@values) is export {
+ our method push(*@values) {
self!fill(0);
pir::push(@!rest, @values.Seq.eager.iterator );
self;
|
The RT System itself - Status changed from 'new' to 'open' |
From @masak<mfollett> rakudo: my %hash; push(%hash<books>, 'Cooking for Geeks'); |
From @cokeNo change in the past year. -- |
From @moritzfixed now, and tested in S02-types/autovivification.t |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#77038 (status was 'resolved')
Searchable as RT77038$
The text was updated successfully, but these errors were encountered: