Fix type assertion bug #619

This commit is contained in:
gingerBill
2020-04-21 23:26:02 +01:00
parent f141e2868d
commit 4236e870d7
2 changed files with 8 additions and 5 deletions

View File

@@ -5750,9 +5750,8 @@ bool check_assignment_arguments(CheckerContext *ctx, Array<Operand> 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<Operand> 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) {