Skip to content

Commit

Permalink
fix: list.map would badly set target list type
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed Jan 28, 2025
1 parent 5e81a20 commit 7e557fd
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/builtin/list.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7e557fd

Please sign in to comment.