From 3e79ec4aef3d2ae109c9d36689cd43550e32fde7 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Sun, 29 Jan 2017 14:27:55 +0000 Subject: Fix untyped to `any` assignments. Fixed crash when arguments with no value are passed --- src/build.c | 2 +- src/check_expr.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/build.c b/src/build.c index 6db7dcd6b..b1dc08bc4 100644 --- a/src/build.c +++ b/src/build.c @@ -148,7 +148,7 @@ String get_filepath_extension(String path) { void init_build_context(BuildContext *bc) { bc->ODIN_VENDOR = str_lit("odin"); - bc->ODIN_VERSION = str_lit("0.0.5e"); + bc->ODIN_VERSION = str_lit("0.0.6b"); bc->ODIN_ROOT = odin_root_dir(); #if defined(GB_SYSTEM_WINDOWS) diff --git a/src/check_expr.c b/src/check_expr.c index e8318a071..defcf7c63 100644 --- a/src/check_expr.c +++ b/src/check_expr.c @@ -138,13 +138,17 @@ i64 check_distance_between_types(Checker *c, Operand *operand, Type *type) { return -1; } if (is_type_untyped(src)) { + if (is_type_any(dst)) { + // NOTE(bill): Anything can cast to `Any` + add_type_info_type(c, s); + return 10; + } if (dst->kind == Type_Basic) { if (operand->mode == Addressing_Constant) { if (check_representable_as_constant(c, operand->value, dst, NULL)) { return 1; - } else { - return -1; } + return -1; } if (src->kind == Type_Basic && src->Basic.kind == Basic_UntypedBool) { if (is_type_boolean(dst)) { @@ -3549,7 +3553,7 @@ Type *check_call_arguments(Checker *c, Operand *operand, Type *proc_type, AstNod for_array(i, ce->args) { Operand o = {0}; check_multi_expr(c, &o, ce->args.e[i]); - if (o.type->kind != Type_Tuple) { + if (o.type == NULL || o.type->kind != Type_Tuple) { array_add(&operands, o); } else { TypeTuple *tuple = &o.type->Tuple; -- cgit v1.2.3