diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-08 19:33:49 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-08 19:33:49 -0400 |
| commit | f86cc6549ff6075c3963fce819391d8d8d6960dc (patch) | |
| tree | 53c6b3dafcdee1d129b09791c3e8b773ff1ac365 | |
| parent | 6d986e1f0419ff76e4ba4b83832a1ae6b7b6e890 (diff) | |
Bugfixes
| -rw-r--r-- | builtins/nums.h | 3 | ||||
| -rw-r--r-- | examples/vectors.tm | 14 | ||||
| -rw-r--r-- | typecheck.c | 2 |
3 files changed, 12 insertions, 7 deletions
diff --git a/builtins/nums.h b/builtins/nums.h index 4205274b..2ac942f4 100644 --- a/builtins/nums.h +++ b/builtins/nums.h @@ -53,4 +53,7 @@ CONSTFUNC static inline float Num32$clamped(float x, float low, float high) { } extern const TypeInfo Num32$info; +#define Num_to_Num32(n) ((Num32_t)(n)) +#define Num32_to_Num(n) ((Num_t)(n)) + // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 diff --git a/examples/vectors.tm b/examples/vectors.tm index 9f0ef20d..8560f9df 100644 --- a/examples/vectors.tm +++ b/examples/vectors.tm @@ -27,10 +27,10 @@ struct Vec2(x,y:Num): return v len := v:length() return Vec2(v.x/len, v.y/len) - func mix(v,other:Vec2, amount:Num)->Vec2: + func mix(a,b:Vec2, amount:Num)->Vec2: return Vec2( - v.x:mix(other.x, amount), - v.y:mix(other.y, amount), + amount:mix(a.x, b.x), + amount:mix(a.y, b.y), ) struct Vec3(x,y,z:Num): @@ -58,11 +58,11 @@ struct Vec3(x,y,z:Num): return v len := v:length() return Vec3(v.x/len, v.y/len, v.z/len) - func mix(v,other:Vec3, amount:Num)->Vec3: + func mix(a,b:Vec3, amount:Num)->Vec3: return Vec3( - v.x:mix(other.x, amount), - v.y:mix(other.y, amount), - v.z:mix(other.z, amount), + amount:mix(a.x, b.x), + amount:mix(a.y, b.y), + amount:mix(a.z, b.z), ) diff --git a/typecheck.c b/typecheck.c index 70d94dbf..5d3ffb48 100644 --- a/typecheck.c +++ b/typecheck.c @@ -263,6 +263,8 @@ void bind_statement(env_t *env, ast_t *statement) bind_statement(env, decl->value); } type_t *type = get_type(env, decl->value); + if (!type) + code_err(decl->value, "I couldn't figure out the type of this value"); if (type->tag == FunctionType) type = Type(ClosureType, type); CORD prefix = namespace_prefix(env->libname, env->namespace); |
