CT variables now follow CT scopes. It's now allowed to mutate CT variables in deeper runtime scopes.

This commit is contained in:
Christoffer Lerno
2022-12-07 16:25:08 +01:00
committed by Christoffer Lerno
parent f7659776fc
commit 1ea5625183
19 changed files with 212 additions and 119 deletions

View File

@@ -9,6 +9,7 @@ fn void main()
var $y = 23;
bool c = $checks(int z = 23, $y += 23, &c);
bool d = $checks(&c, $y, int yy = 23);
int z = $y;
io::printfln("%s %s %s", b, $y, c);
}
@@ -16,5 +17,6 @@ fn void main()
store i32 0
store i8 0
store i8 0
store i8 1
store i8 1
store i32 46

View File

@@ -18,7 +18,8 @@ fn void main()
int x = 0;
@cofefe(x += 1);
@cofefe(xx());
@cofefe($x += 1); // #error: Cannot modify '$x' inside of a runtime scope.
@cofefe($x += 1);
$assert($x == 2);
@cofefe(y += 1); // #error: 'y' could not be found
}

View File

@@ -508,7 +508,7 @@ after_check100: ; preds = %if.then
panic_block: ; preds = %assign_optional
%160 = load void (i8*, i64, i8*, i64, i8*, i64, i32)*, void (i8*, i64, i8*, i64, i8*, i64, i32)** @std_core_builtin_panic, align 8
call void %160(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.panic_msg, i64 0, i64 0), i64 27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.file, i64 0, i64 0), i64 6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.func, i64 0, i64 0), i64 4, i32 245)
call void %160(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.panic_msg, i64 0, i64 0), i64 27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.file, i64 0, i64 0), i64 6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.func, i64 0, i64 0), i64 4, i32 246)
unreachable
noerr_block: ; preds = %after_check100

View File

@@ -9,6 +9,7 @@ fn void main()
var $y = 23;
bool c = $checks(int z = 23, $y += 23, &c);
bool d = $checks(&c, $y, int yy = 23);
int z = $y;
io::printfln("%s %s %s", b, $y, c);
}
@@ -16,5 +17,6 @@ fn void main()
store i32 0
store i8 0
store i8 0
store i8 1
store i8 1
store i32 46

View File

@@ -18,7 +18,8 @@ fn void main()
int x = 0;
@cofefe(x += 1);
@cofefe(xx());
@cofefe($x += 1); // #error: Cannot modify '$x' inside of a runtime scope.
@cofefe($x += 1);
$assert($x == 2);
@cofefe(y += 1); // #error: 'y' could not be found
}

View File

@@ -364,7 +364,7 @@ after_check67: ; preds = %if.then
panic_block: ; preds = %assign_optional
%81 = load ptr, ptr @std_core_builtin_panic, align 8
call void %81(ptr @.panic_msg, i64 27, ptr @.file, i64 6, ptr @.func, i64 4, i32 245)
call void %81(ptr @.panic_msg, i64 27, ptr @.file, i64 6, ptr @.func, i64 4, i32 246)
unreachable
noerr_block: ; preds = %after_check67