diff options
| author | David Rubin <daviru007@icloud.com> | 2025-08-09 18:47:55 -0700 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-08-13 13:55:57 +0100 |
| commit | 8e02f9f70df97891aabfce615a1ef43434bc5c1f (patch) | |
| tree | 4fae570ff474dbeb7cdafa3fd1840d3e71de3df7 /lib/std | |
| parent | 6e90ce25364b02555a3ca46013f85b2e80e98705 (diff) | |
| download | zig-8e02f9f70df97891aabfce615a1ef43434bc5c1f.tar.gz zig-8e02f9f70df97891aabfce615a1ef43434bc5c1f.zip | |
sema: strip `@splat` operand result type before checking it
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/zig/AstGen.zig | 5 | ||||
| -rw-r--r-- | lib/std/zig/Zir.zig | 16 |
2 files changed, 12 insertions, 9 deletions
diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig index 99c80816ad..c208661359 100644 --- a/lib/std/zig/AstGen.zig +++ b/lib/std/zig/AstGen.zig @@ -2697,7 +2697,7 @@ fn addEnsureResult(gz: *GenZir, maybe_unused_result: Zir.Inst.Ref, statement: As .array_type_sentinel, .elem_type, .indexable_ptr_elem_type, - .vec_arr_elem_type, + .splat_op_result_ty, .vector_type, .indexable_ptr_len, .anyframe_type, @@ -9526,10 +9526,9 @@ fn builtinCall( }); return rvalue(gz, ri, result, node); }, - .splat => { const result_type = try ri.rl.resultTypeForCast(gz, node, builtin_name); - const elem_type = try gz.addUnNode(.vec_arr_elem_type, result_type, node); + const elem_type = try gz.addUnNode(.splat_op_result_ty, result_type, node); const scalar = try expr(gz, scope, .{ .rl = .{ .ty = elem_type } }, params[0]); const result = try gz.addPlNode(.splat, node, Zir.Inst.Bin{ .lhs = result_type, diff --git a/lib/std/zig/Zir.zig b/lib/std/zig/Zir.zig index f6781a74a2..b00d0d78c9 100644 --- a/lib/std/zig/Zir.zig +++ b/lib/std/zig/Zir.zig @@ -273,9 +273,13 @@ pub const Inst = struct { /// element type. Emits a compile error if the type is not an indexable pointer. /// Uses the `un_node` field. indexable_ptr_elem_type, - /// Given a vector or array type, returns its element type. + /// Given a vector or array type, strips off any error unions or + /// optionals layered on top and returns its element type. + /// + /// `!?[N]T` -> `T` + /// /// Uses the `un_node` field. - vec_arr_elem_type, + splat_op_result_ty, /// Given a pointer to an indexable object, returns the len property. This is /// used by for loops. This instruction also emits a for-loop specific compile /// error if the indexable object is not indexable. @@ -1098,7 +1102,7 @@ pub const Inst = struct { .vector_type, .elem_type, .indexable_ptr_elem_type, - .vec_arr_elem_type, + .splat_op_result_ty, .indexable_ptr_len, .anyframe_type, .as_node, @@ -1395,7 +1399,7 @@ pub const Inst = struct { .vector_type, .elem_type, .indexable_ptr_elem_type, - .vec_arr_elem_type, + .splat_op_result_ty, .indexable_ptr_len, .anyframe_type, .as_node, @@ -1630,7 +1634,7 @@ pub const Inst = struct { .vector_type = .pl_node, .elem_type = .un_node, .indexable_ptr_elem_type = .un_node, - .vec_arr_elem_type = .un_node, + .splat_op_result_ty = .un_node, .indexable_ptr_len = .un_node, .anyframe_type = .un_node, .as_node = .pl_node, @@ -4173,7 +4177,7 @@ fn findTrackableInner( .vector_type, .elem_type, .indexable_ptr_elem_type, - .vec_arr_elem_type, + .splat_op_result_ty, .indexable_ptr_len, .anyframe_type, .as_node, |
