fix: semantic restrictions for global variables, constant folding
This commit is contained in:
parent
cbcc796f1e
commit
9b5cd4038f
13 changed files with 569 additions and 375 deletions
|
|
@ -68,6 +68,29 @@ test "compiler: invalid divert target" {
|
|||
);
|
||||
}
|
||||
|
||||
test "compiler: global variable restrictions" {
|
||||
try testEqual(
|
||||
\\VAR a = b
|
||||
\\VAR b = a
|
||||
,
|
||||
\\<STDIN>:1:9: error: global variable assignments cannot refer to other variables
|
||||
\\1 | VAR a = b
|
||||
\\ | ^
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "compiler: constant cycle detection" {
|
||||
try testEqual(
|
||||
\\CONST a = a
|
||||
,
|
||||
\\<STDIN>:1:11: error: cycle detected in constant initializer
|
||||
\\1 | CONST a = a
|
||||
\\ | ^
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
fn testEqual(source_bytes: [:0]const u8, expected_error: []const u8) !void {
|
||||
const gpa = std.testing.allocator;
|
||||
var arena_allocator = std.heap.ArenaAllocator.init(gpa);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue