stage1: Fix type-checking of unary neg for vector types

Validate the vector element type as done for the scalar case.

Fixes #6708
This commit is contained in:
LemonBoy
2020-10-17 10:06:14 +02:00
committed by Andrew Kelley
parent e51bc19e4a
commit 2a256d5ea0
5 changed files with 19 additions and 61 deletions

View File

@@ -8172,14 +8172,19 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
, &[_][]const u8{
"tmp.zig:2:9: error: @wasmMemoryGrow is a wasm32 feature only",
});
cases.add("Issue #5586: Make unary minus for unsigned types a compile error",
\\export fn f(x: u32) u32 {
\\export fn f1(x: u32) u32 {
\\ const y = -%x;
\\ return -y;
\\}
\\const V = @import("std").meta.Vector;
\\export fn f2(x: V(4, u32)) V(4, u32) {
\\ const y = -%x;
\\ return -y;
\\}
, &[_][]const u8{
"tmp.zig:3:12: error: negation of type 'u32'",
"tmp.zig:8:12: error: negation of type 'u32'",
});
cases.add("Issue #5618: coercion of ?*c_void to *c_void must fail.",