浏览代码

Fix #5107

Fixes #5107 by checking whether `result_count` is non-zero before indexing `type->Proc.results->Tuple.variables`.
Jeroen van Rijn 4 月之前
父节点
当前提交
9681d88cd3
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/check_expr.cpp

+ 1 - 1
src/check_expr.cpp

@@ -8143,7 +8143,7 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c
 			type = pt;
 		}
 		type = base_type(type);
-		if (type->kind == Type_Proc && type->Proc.optional_ok) {
+		if (type->kind == Type_Proc && type->Proc.optional_ok && type->Proc.result_count > 0) {
 			operand->mode = Addressing_OptionalOk;
 			operand->type = type->Proc.results->Tuple.variables[0]->type;
 			if (operand->expr != nullptr && operand->expr->kind == Ast_CallExpr) {