diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-06-13 09:56:15 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-06-13 09:56:15 -0400 |
commit | a08e6a8f792cb5f610040374c11b2081d44437f5 (patch) | |
tree | 347035139624212fae55ae1a7baf4310c8a7c362 /type-check.c | |
parent | 41e167cb14493a30daaacced9d9a34dbeba241d0 (diff) |
Type check string types
Diffstat (limited to 'type-check.c')
-rw-r--r-- | type-check.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/type-check.c b/type-check.c index ef9c2dc..c727ed5 100644 --- a/type-check.c +++ b/type-check.c @@ -184,6 +184,12 @@ is_label (ast_type_spec_t *type) } static gboolean +is_string (ast_type_spec_t *type) +{ + return type->common.type == AST_STRING_TYPE; +} + +static gboolean assignable (ast_type_spec_t *left, ast_type_spec_t *right) { @@ -226,6 +232,9 @@ assignable (ast_type_spec_t *left, if (is_array (left) && is_null (right)) return TRUE; + if (is_string (left) && is_string (right)) + return TRUE; + return FALSE; } @@ -495,7 +504,10 @@ type_check_arguments (ast_type_spec_t **types, for (i = 0; types[i] != NULL; ++i) { if (!assignable (types[i], arguments[i]->common.type_spec)) + { + g_print ("type %d vs %d\n", arguments[i]->common.type_spec->common.type, types[i]->common.type); return report_error ("Type error in argument list\n"); + } } return TRUE; |