From 40c4c25e2b5e2242c3180cd8564dc22697bf363f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 18 Feb 2023 18:56:37 -0700 Subject: Sema: add missing coercion when checking for loop len --- src/Sema.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Sema.zig b/src/Sema.zig index 6e8d77475e..fcdb1ce518 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -3934,12 +3934,13 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. .for_node_offset = inst_data.src_node, .input_index = i, } }; - const arg_len = if (is_int) object else l: { + const arg_len_uncoerced = if (is_int) object else l: { try checkIndexable(sema, block, arg_src, object_ty); if (!object_ty.indexableHasLen()) continue; break :l try sema.fieldVal(block, arg_src, object, "len", arg_src); }; + const arg_len = try sema.coerce(block, Type.usize, arg_len_uncoerced, arg_src); if (len == .none) { len = arg_len; len_idx = i; -- cgit v1.2.3