From 7e557fddd72fac69d3fa9eda8c24c4c68234a4ff Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Tue, 28 Jan 2025 22:00:16 +0100 Subject: [PATCH] fix: list.map would badly set target list type --- src/builtin/list.zig | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/builtin/list.zig b/src/builtin/list.zig index d431d55f..de321412 100644 --- a/src/builtin/list.zig +++ b/src/builtin/list.zig @@ -423,12 +423,29 @@ pub fn map(ctx: *NativeCtx) c_int { const list = ObjList.cast(ctx.vm.peek(1).obj()).?; const closure = ctx.vm.peek(0); - const mapped_type = ObjClosure.cast(closure.obj()).?.function.type_def.resolved_type.?.Function.return_type; + const mapped_type = ObjClosure.cast(closure.obj()).? + .function + .type_def.resolved_type.?.Function + .return_type; + var new_list: *ObjList = ctx.vm.gc.allocateObject( ObjList, ObjList.init( ctx.vm.gc.allocator, - mapped_type, + ctx.vm.gc.type_registry.getTypeDef( + .{ + .def_type = .List, + .resolved_type = .{ + .List = ObjList.ListDef.init( + mapped_type, + false, + ), + }, + }, + ) catch { + ctx.vm.panic("Out of memory"); + unreachable; + }, ) catch { ctx.vm.panic("Out of memory"); unreachable;