diff --git a/editor/src/lang/ast.rs b/editor/src/lang/ast.rs index f95266fb79..80557ea41e 100644 --- a/editor/src/lang/ast.rs +++ b/editor/src/lang/ast.rs @@ -270,17 +270,17 @@ impl ShallowClone for ValueDef { #[derive(Debug)] pub enum FunctionDef { WithAnnotation { - name: Symbol, // 8B - arguments: PoolVec<(Pattern2, Type2)>, // 8B - rigids: NodeId, // 4B - return_type: TypeId, // 4B - body: ExprId, // 4B + name: Symbol, // 8B + arguments: PoolVec<(PatternId, Type2)>, // 8B + rigids: NodeId, // 4B + return_type: TypeId, // 4B + body: ExprId, // 4B }, NoAnnotation { - name: Symbol, // 8B - arguments: PoolVec<(Pattern2, Variable)>, // 8B - return_var: Variable, // 4B - body: ExprId, // 4B + name: Symbol, // 8B + arguments: PoolVec<(PatternId, Variable)>, // 8B + return_var: Variable, // 4B + body: ExprId, // 4B }, } diff --git a/editor/src/lang/def.rs b/editor/src/lang/def.rs index 0cd3b25ba0..c179145a7c 100644 --- a/editor/src/lang/def.rs +++ b/editor/src/lang/def.rs @@ -514,7 +514,7 @@ fn canonicalize_pending_def<'a>( // parent commit for the bug this fixed! let refs = References::new(); - let arguments: PoolVec<(Pattern2, Type2)> = + let arguments: PoolVec<(PatternId, Type2)> = PoolVec::with_capacity(closure_args.len() as u32, env.pool); let return_type: TypeId; @@ -551,9 +551,7 @@ fn canonicalize_pending_def<'a>( for (node_id, ((_, pattern_id), typ)) in arguments.iter_node_ids().zip(it.into_iter()) { - let pattern = &env.pool[pattern_id]; - - env.pool[node_id] = (pattern.shallow_clone(), typ); + env.pool[node_id] = (pattern_id, typ); } return_type = return_type_id; @@ -683,16 +681,14 @@ fn canonicalize_pending_def<'a>( // parent commit for the bug this fixed! let refs = References::new(); - let arguments: PoolVec<(Pattern2, Variable)> = + let arguments: PoolVec<(PatternId, Variable)> = PoolVec::with_capacity(closure_args.len() as u32, env.pool); let it: Vec<_> = closure_args.iter(env.pool).map(|(x, y)| (*x, *y)).collect(); for (node_id, (_, pattern_id)) in arguments.iter_node_ids().zip(it.into_iter()) { - let pattern = &env.pool[pattern_id]; - - env.pool[node_id] = (pattern.shallow_clone(), env.var_store.fresh()); + env.pool[node_id] = (pattern_id, env.var_store.fresh()); } let function_def = FunctionDef::NoAnnotation { diff --git a/editor/src/lang/pool.rs b/editor/src/lang/pool.rs index e68199e339..a35a7f63f0 100644 --- a/editor/src/lang/pool.rs +++ b/editor/src/lang/pool.rs @@ -13,6 +13,7 @@ use libc::{c_void, MAP_ANONYMOUS, MAP_PRIVATE, PROT_READ, PROT_WRITE}; use roc_can::expected::Expected; use roc_can::expected::PExpected; +use std::any::type_name; use std::cmp::Ordering; use std::marker::PhantomData; use std::mem::size_of; @@ -322,7 +323,12 @@ impl<'a, T: 'a + Sized> PoolVec { } pub fn with_capacity(len: u32, pool: &mut Pool) -> Self { - debug_assert!(size_of::() <= NODE_BYTES, "{}", size_of::()); + debug_assert!( + size_of::() <= NODE_BYTES, + "{} has a size of {}", + type_name::(), + size_of::() + ); if len == 0 { Self::empty(pool)