Merge pull request #12796 from Vexu/referenced-by-v2
stage2: add referenced by trace to compile errors attempt #2 (+ some fixes)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
pub export fn entry() void {
|
||||
var a = false;
|
||||
const arr1 = .{ 1, 2, 3 };
|
||||
loop: inline for (arr1) |val1| {
|
||||
_ = val1;
|
||||
if (a) {
|
||||
const arr = .{ 1, 2, 3 };
|
||||
inline for (arr) |val| {
|
||||
if (val < 3) continue :loop;
|
||||
if (val != 3) unreachable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :9:30: error: comptime control flow inside runtime block
|
||||
// :6:13: note: runtime control flow here
|
||||
@@ -0,0 +1,25 @@
|
||||
fn foo() bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
pub export fn entry() void {
|
||||
const Widget = union(enum) { a: u0 };
|
||||
|
||||
comptime var a = 1;
|
||||
const info = @typeInfo(Widget).Union;
|
||||
inline for (info.fields) |field| {
|
||||
if (foo()) {
|
||||
switch (field.field_type) {
|
||||
u0 => a = 2,
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :13:27: error: store to comptime variable depends on runtime condition
|
||||
// :11:16: note: runtime condition here
|
||||
@@ -10,4 +10,3 @@ export fn entry() void {
|
||||
// target=native
|
||||
//
|
||||
// :1:1: error: dependency loop detected
|
||||
// :2:19: note: referenced here
|
||||
|
||||
Reference in New Issue
Block a user