sub _expand_args {
my ($self, $state, %spec) = @_;
my %args;
- @args{keys %spec} = map $self->_expand_argspec($state, $_), values %spec;
+ foreach my $key (keys %spec) {
+ ($state, $args{$key}) = $self->_expand_argspec($state, $spec{$key});
+ }
return $state->expand_vars(%args);
}
sub _expand_argspec {
my ($self, $state, $spec) = @_;
if (!ref($spec)) {
- $state->scope_var($spec)
- } elsif (ref($spec) eq 'ARRAY') {
- if ($spec->[0] eq 'value') {
- +{ bound_value => $spec->[1] };
- } else {
- die "Arrayref in argspec is not value";
- }
+ ($state->has_scope_var($spec)
+ ? ($state, $state->scope_var($spec))
+ : (map { $_, $_->scope_var($spec) } $state->assign_vars($spec => {})));
} elsif (ref($spec) eq 'SCALAR' or ref($spec) eq 'REF') {
- return +{ bound_value => $$spec };
+ return ($state, +{ bound_value => $$spec });
} else {
die "Argspec incomprehensible";
}