Skip to content

Commit 5e3b9c3

Browse files
committed
Enable and fix array literal assertion test
Uncommented the array literal assertion in both the compiler test and the test case file. Updated JIT code generation to use gen_copy for array initialization, ensuring correct handling of array literals.
1 parent 9e9a0ec commit 5e3b9c3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/compiler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,14 @@ mod tests {
335335
jit(code);
336336
}
337337

338-
#[test]
338+
#[test]
339339
fn test_array_literal() {
340340
let code = r#"
341341
assert(cond: bool) → void
342342
343343
main {
344344
var a = [42]
345-
// assert(a[0] == 42)
345+
assert(a[0] == 42)
346346
}
347347
"#;
348348

src/jit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<'a> FunctionTranslator<'a> {
392392

393393
if let Some(init_id) = init {
394394
let init_value = self.translate_expr(*init_id, decl, decls);
395-
self.builder.ins().stack_store(init_value, slot, 0);
395+
self.gen_copy(*ty, addr, init_value, decls);
396396
}
397397

398398
self.builder.ins().iconst(I32, 0)

tests/cases/arrays/array_literal.lyte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ assert(cond: bool) → void
55

66
main {
77
var a = [42]
8-
// assert(a[0] == 42)
8+
assert(a[0] == 42)
99
}

0 commit comments

Comments
 (0)