[Bps-public-commit] lcore branch, master, updated. f6be0770584eab193982999d4f7c0a3f91b48982
clkao at bestpractical.com
clkao at bestpractical.com
Tue Oct 20 10:10:34 EDT 2009
The branch, master has been updated
via f6be0770584eab193982999d4f7c0a3f91b48982 (commit)
from 768f225ec43d3651fe2e58a9e883d1b9540403c7 (commit)
Summary of changes:
lib/LCore/Expression/TypedApplication.pm | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
- Log -----------------------------------------------------------------
commit f6be0770584eab193982999d4f7c0a3f91b48982
Author: Chia-liang Kao <clkao at bestpractical.com>
Date: Tue Oct 20 22:10:06 2009 +0800
type checking for array inner type.
diff --git a/lib/LCore/Expression/TypedApplication.pm b/lib/LCore/Expression/TypedApplication.pm
index 839b69e..a684d74 100644
--- a/lib/LCore/Expression/TypedApplication.pm
+++ b/lib/LCore/Expression/TypedApplication.pm
@@ -16,7 +16,19 @@ around 'get_operands' => sub {
return @args if !$incoming || $incoming =~ m/^ArrayRef/;
}
if ($#args >= $#params) {
+ my ($inner_type) = map { Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($_) }
+ $params[-1]->type =~ m/ArrayRef\[(.*)\]/;
my @arraify = @args[$#params..$#args];
+ # XXX refactor to share with the type checking in mk_expression
+ if ($inner_type) {
+ for (0..$#arraify) {
+ my $incoming = $self->_get_arg_return_type($env, $arraify[$_])
+ or next;
+ die "type mismatch for array element @{[ 1 + $_ ]}: expecting $inner_type, got $incoming"
+ unless $incoming->is_a_type_of($inner_type);
+ }
+ }
+
my $x = sub { my $env = shift; [map { $_->($env) } @arraify] };
splice(@args, $#params);
push @args, $x;
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list