mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
CT variables now follow CT scopes. It's now allowed to mutate CT variables in deeper runtime scopes.
This commit is contained in:
committed by
Christoffer Lerno
parent
f7659776fc
commit
1ea5625183
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user