From 4236e870d7090f09c0ff0b90873125573cb2910d Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 21 Apr 2020 23:26:02 +0100 Subject: [PATCH] Fix type assertion bug #619 --- core/runtime/internal.odin | 8 ++++++-- src/check_expr.cpp | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/runtime/internal.odin b/core/runtime/internal.odin index 9dd166d8e..80094f28a 100644 --- a/core/runtime/internal.odin +++ b/core/runtime/internal.odin @@ -235,8 +235,12 @@ print_caller_location :: proc(fd: os.Handle, using loc: Source_Code_Location) { os.write_byte(fd, ')'); } print_typeid :: proc(fd: os.Handle, id: typeid) { - ti := type_info_of(id); - print_type(fd, ti); + if id == nil { + os.write_string(fd, "nil"); + } else { + ti := type_info_of(id); + print_type(fd, ti); + } } print_type :: proc(fd: os.Handle, ti: ^Type_Info) { if ti == nil { diff --git a/src/check_expr.cpp b/src/check_expr.cpp index d43d51e21..af9750ee4 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5750,9 +5750,8 @@ bool check_assignment_arguments(CheckerContext *ctx, Array const &lhs, optional_ok = true; tuple_index += 2; - } else if (o.mode == Addressing_OptionalOk) { + } else if (o.mode == Addressing_OptionalOk && is_type_tuple(o.type)) { Type *tuple = o.type; - GB_ASSERT(is_type_tuple(tuple)); GB_ASSERT(tuple->Tuple.variables.count == 2); Ast *expr = unparen_expr(o.expr); if (expr->kind == Ast_CallExpr) { @@ -5769,7 +5768,7 @@ bool check_assignment_arguments(CheckerContext *ctx, Array const &lhs, } } else { TypeTuple *tuple = &o.type->Tuple; - if (o.mode == Addressing_OptionalOk && lhs.count == 1) { + if (o.mode == Addressing_OptionalOk && is_type_tuple(o.type) && lhs.count == 1) { GB_ASSERT(tuple->variables.count == 2); Ast *expr = unparen_expr(o.expr); if (expr->kind == Ast_CallExpr) {