mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Fixed erased with nullable unwrapped union
This commit is contained in:
parent
5e9a06e537
commit
937e042c8f
4 changed files with 105 additions and 10 deletions
|
@ -21,3 +21,21 @@ pub fn unbox<'a>(symbol: Symbol, element_layout: &'a InLayout<'a>) -> Expr<'a> {
|
|||
index: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn box_nullable<'a>(symbol: &'a Symbol, element_layout: &'a InLayout<'a>) -> Expr<'a> {
|
||||
Expr::Tag {
|
||||
tag_layout: UnionLayout::boxed_erased_value(element_layout),
|
||||
tag_id: 0,
|
||||
arguments: std::slice::from_ref(symbol),
|
||||
reuse: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unbox_nullable<'a>(symbol: Symbol, element_layout: &'a InLayout<'a>) -> Expr<'a> {
|
||||
Expr::UnionAtIndex {
|
||||
structure: symbol,
|
||||
tag_id: 0,
|
||||
union_layout: UnionLayout::boxed_erased_value(element_layout),
|
||||
index: 0,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,8 @@ use crate::{
|
|||
};
|
||||
|
||||
use super::{
|
||||
boxed::{self, unbox},
|
||||
with_hole, BranchInfo, Call, CallType, CapturedSymbols, Env, ErasedField, Expr, JoinPointId,
|
||||
Param, Procs, Stmt, UpdateModeId,
|
||||
boxed, with_hole, BranchInfo, Call, CallType, CapturedSymbols, Env, ErasedField, Expr,
|
||||
JoinPointId, Param, Procs, Stmt, UpdateModeId,
|
||||
};
|
||||
|
||||
fn index_erased_function<'a>(
|
||||
|
@ -351,7 +350,7 @@ pub fn build_erased_function<'a>(
|
|||
|
||||
let result = Stmt::Let(
|
||||
value.unwrap(),
|
||||
boxed::box_(env.arena.alloc(stack_captures), stack_captures_layout),
|
||||
boxed::box_nullable(env.arena.alloc(stack_captures), stack_captures_layout),
|
||||
boxed_captures_layout,
|
||||
env.arena.alloc(result),
|
||||
);
|
||||
|
@ -485,7 +484,7 @@ pub fn unpack_closure_data<'a>(
|
|||
|
||||
hole = Stmt::Let(
|
||||
stack_captures,
|
||||
unbox(heap_captures, stack_captures_layout),
|
||||
boxed::unbox_nullable(heap_captures, stack_captures_layout),
|
||||
*stack_captures_layout,
|
||||
env.arena.alloc(hole),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue