diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 18:56:37 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 19:20:19 -0700 |
| commit | 40c4c25e2b5e2242c3180cd8564dc22697bf363f (patch) | |
| tree | 1afd7f26c0fa5b0b8bb170c3d4520895fe64d0a3 /src | |
| parent | 12a7a0d76f9435c8c538f762daa79a49ca0470af (diff) | |
| download | zig-40c4c25e2b5e2242c3180cd8564dc22697bf363f.tar.gz zig-40c4c25e2b5e2242c3180cd8564dc22697bf363f.zip | |
Sema: add missing coercion when checking for loop len
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 3 |
1 files changed, 2 insertions, 1 deletions
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; |
