Commit 0eddf0cbc0

Veikka Tuominen <git@vexu.eu>
2022-12-17 23:45:07
Sema: fix condition for non-pointer noalias error
Closes #13987
1 parent 3db8cff
Changed files (2)
src
test
src/Sema.zig
@@ -8820,7 +8820,9 @@ fn analyzeParameter(
         };
         return sema.failWithOwnedErrorMsg(msg);
     }
-    if (!this_generic and is_noalias and !param.ty.isPtrAtRuntime()) {
+    if (!sema.is_generic_instantiation and !this_generic and is_noalias and
+        !(param.ty.zigTypeTag() == .Pointer or param.ty.isPtrLikeOptional()))
+    {
         return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{});
     }
 }
test/cases/compile_errors/noalias_on_non_pointer_param.zig
@@ -1,6 +1,12 @@
 fn f(noalias x: i32) void { _ = x; }
 export fn entry() void { f(1234); }
 
+fn generic(comptime T: type, noalias _: [*]T, noalias _: [*]const T, _: usize) void  {}
+comptime { _ = generic; }
+
+fn slice(noalias _: []u8) void  {}
+comptime { _ = slice; }
+
 // error
 // backend=stage2
 // target=native