diff options
| -rw-r--r-- | examples/game/raylib.tm | 4 | ||||
| -rw-r--r-- | examples/game/world.tm | 2 | ||||
| -rw-r--r-- | src/typecheck.c | 8 |
3 files changed, 9 insertions, 5 deletions
diff --git a/examples/game/raylib.tm b/examples/game/raylib.tm index fc0affb9..ad248e4f 100644 --- a/examples/game/raylib.tm +++ b/examples/game/raylib.tm @@ -19,7 +19,7 @@ struct Vector2(x,y:Num32; extern): func negative(v:Vector2->Vector2; inline): return Vector2(-v.x, -v.y) func dot(a,b:Vector2->Num32; inline): - return ((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y))! + return ((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y)) func cross(a,b:Vector2->Num32; inline): return a.x*b.y - a.y*b.x func scaled_by(v:Vector2, k:Num32->Vector2; inline): @@ -27,7 +27,7 @@ struct Vector2(x,y:Num32; extern): func divided_by(v:Vector2, divisor:Num32->Vector2; inline): return Vector2(v.x/divisor, v.y/divisor) func length(v:Vector2->Num32; inline): - return (v.x*v.x + v.y*v.y)!:sqrt() + return (v.x*v.x + v.y*v.y):sqrt() func dist(a,b:Vector2->Num32; inline): return a:minus(b):length() func angle(v:Vector2->Num32; inline): diff --git a/examples/game/world.tm b/examples/game/world.tm index 8b721c5c..76acac6b 100644 --- a/examples/game/world.tm +++ b/examples/game/world.tm @@ -38,7 +38,7 @@ func solve_overlap(a_pos:Vector2, a_size:Vector2, b_pos:Vector2, b_size:Vector2 return Vector2(0, 0) struct World(player:@Player, goal:@Box, boxes:@[@Box], dt_accum=Num32(0.0), won=no): - DT := (Num32(1.)/Num32(60.))! + DT := (Num32(1.)/Num32(60.)) STIFFNESS := Num32(0.3) func update(w:@World, dt:Num32): diff --git a/src/typecheck.c b/src/typecheck.c index 4341748b..85f159c9 100644 --- a/src/typecheck.c +++ b/src/typecheck.c @@ -1516,7 +1516,9 @@ Table_t *get_arg_bindings(env_t *env, arg_t *spec_args, arg_ast_t *call_args, bo for (arg_t *spec_arg = spec_args; spec_arg; spec_arg = spec_arg->next) { if (!streq(call_arg->name, spec_arg->name)) continue; type_t *spec_type = get_arg_type(env, spec_arg); - if (!(type_eq(call_type, spec_type) || (promotion_allowed && can_promote(call_type, spec_type)) + type_t *complete_call_type = is_incomplete_type(call_type) ? most_complete_type(call_type, spec_type) : call_type; + if (!complete_call_type) return NULL; + if (!(type_eq(complete_call_type, spec_type) || (promotion_allowed && can_promote(complete_call_type, spec_type)) || (promotion_allowed && call_arg->value->tag == Int && is_numeric_type(spec_type)) || (promotion_allowed && call_arg->value->tag == Num && spec_type->tag == NumType))) return NULL; @@ -1536,7 +1538,9 @@ Table_t *get_arg_bindings(env_t *env, arg_t *spec_args, arg_ast_t *call_args, bo for (; unused_args; unused_args = unused_args->next) { if (unused_args->name) continue; // Already handled the keyword args type_t *call_type = get_arg_ast_type(env, unused_args); - if (!(type_eq(call_type, spec_type) || (promotion_allowed && can_promote(call_type, spec_type)) + type_t *complete_call_type = is_incomplete_type(call_type) ? most_complete_type(call_type, spec_type) : call_type; + if (!complete_call_type) return NULL; + if (!(type_eq(complete_call_type, spec_type) || (promotion_allowed && can_promote(complete_call_type, spec_type)) || (promotion_allowed && unused_args->value->tag == Int && is_numeric_type(spec_type)) || (promotion_allowed && unused_args->value->tag == Num && spec_type->tag == NumType))) return NULL; // Positional arg trying to fill in |
