forked from ziglang/zig
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add error for discarding if/while pointer capture
- Loading branch information
1 parent
070cb24
commit ac5bca6
Showing
2 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export fn a() void { | ||
for (.{}) |*_| {} | ||
} | ||
|
||
export fn b() void { | ||
switch (0) { | ||
else => |*_| {}, | ||
} | ||
} | ||
|
||
export fn c() void { | ||
if (null) |*_| {} | ||
} | ||
|
||
export fn d() void { | ||
while (null) |*_| {} | ||
} | ||
|
||
// error | ||
// backend=stage2 | ||
// target=native | ||
// | ||
// :2:16: error: pointer modifier invalid on discard | ||
// :7:18: error: pointer modifier invalid on discard | ||
// :12:16: error: pointer modifier invalid on discard | ||
// :16:19: error: pointer modifier invalid on discard |