aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-28 14:17:05 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-28 14:17:05 -0700
commitb6ccde47adeb0dbd7b39150c36498100e0d98075 (patch)
treec9fff157c08701cd6d6849a1c95fddd5385e1c86 /test
parent691c7cb3cd3cc6cb4f6324d0ad4a5c3e2e8ff94c (diff)
downloadzig-b6ccde47adeb0dbd7b39150c36498100e0d98075.tar.gz
zig-b6ccde47adeb0dbd7b39150c36498100e0d98075.zip
Sema: allow mixing array and vector operands
* Added peer type resolution for arrays and vectors: the vector type is selected. * Fixed passing the lhs type or rhs type instead of the peer resolved type when calling Value methods during analyzeArithmetic handling of comptime expressions. * `checkVectorizableBinaryOperands` now allows mixing vectors and arrays, as long as one of the operands is a vector. This matches stage1's handling of `^=` but apparently stage1 is inconsistent and does not handle e.g. `*=`. stage2 now will always allow mixing vector and array operands for all operations.
Diffstat (limited to 'test')
-rw-r--r--test/behavior/vector.zig24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig
index 1651e8107b..ccf22a2094 100644
--- a/test/behavior/vector.zig
+++ b/test/behavior/vector.zig
@@ -879,3 +879,27 @@ test "saturating shift-left" {
try S.doTheTest();
comptime try S.doTheTest();
}
+
+test "multiplication-assignment operator with an array operand" {
+ if (builtin.zig_backend == .stage1) {
+ // stage1 emits a compile error
+ return error.SkipZigTest;
+ }
+ if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const S = struct {
+ fn doTheTest() !void {
+ var x: @Vector(3, i32) = .{ 1, 2, 3 };
+ x *= [_]i32{ 4, 5, 6 };
+ try expect(x[0] == 4);
+ try expect(x[1] == 10);
+ try expect(x[2] == 18);
+ }
+ };
+ try S.doTheTest();
+ comptime try S.doTheTest();
+}