@ enum type

This commit is contained in:
agra
2026-02-14 14:52:39 +02:00
parent fe7efeadb0
commit d61c6488f3
12 changed files with 164 additions and 41 deletions

View File

@@ -104,7 +104,7 @@ pub const Value = union(enum) {
},
.pointer_val => |pv| {
const inner = try pv.target[0].format(allocator);
return std.fmt.allocPrint(allocator, "&{s}", .{inner});
return std.fmt.allocPrint(allocator, "@{s}", .{inner});
},
.null_val => allocator.dupe(u8, "null"),
};
@@ -1947,7 +1947,7 @@ test "VM: address-of and deref" {
defer arena.deinit();
const alloc = arena.allocator();
// x := 42; ptr := &x; ptr.*
// x := 42; ptr := @x; ptr.*
const code = [_]Instruction{
.{ .push_int = 42 },
.{ .set_local = 0 }, // x = 42
@@ -1973,7 +1973,7 @@ test "VM: deref_set modifies through pointer" {
defer arena.deinit();
const alloc = arena.allocator();
// x := 10; ptr := &x; ptr.* = 99; x
// x := 10; ptr := @x; ptr.* = 99; x
const code = [_]Instruction{
.{ .push_int = 10 },
.{ .set_local = 0 }, // x = 10
@@ -2021,7 +2021,7 @@ test "VM: pointer to struct field access" {
defer arena.deinit();
const alloc = arena.allocator();
// Build: struct{x: 10, y: 20}, &struct, get_field(1) — auto-deref
// Build: struct{x: 10, y: 20}, @struct, get_field(1) — auto-deref
const code = [_]Instruction{
.{ .push_int = 10 },
.{ .push_int = 20 },