From 4e9387cbdabc2f6b396c35b5d7625439df94c7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Besnier?= Date: Mon, 28 Dec 2020 21:17:27 +0100 Subject: [PATCH] fix compile issues --- cli/src/repl/eval.rs | 15 ++++++++++++--- compiler/can/src/expr.rs | 4 +++- compiler/can/src/operator.rs | 22 ++++++++++++++++------ editor/src/expr.rs | 8 ++++---- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/cli/src/repl/eval.rs b/cli/src/repl/eval.rs index 5e4d07e6bc..7e437ba1e7 100644 --- a/cli/src/repl/eval.rs +++ b/cli/src/repl/eval.rs @@ -93,7 +93,10 @@ fn jit_to_ast_help<'a>( ), Layout::Builtin(Builtin::EmptyList) => { Ok(run_jit_function!(lib, main_fn_name, &'static str, |_| { - Expr::List(&[]) + Expr::List { + items: &[], + final_comments: &[], + } })) } Layout::Builtin(Builtin::List(_, elem_layout)) => Ok(run_jit_function!( @@ -251,7 +254,10 @@ fn ptr_to_ast<'a>( num_to_ast(env, f64_to_ast(env.arena, num), content) } - Layout::Builtin(Builtin::EmptyList) => Expr::List(&[]), + Layout::Builtin(Builtin::EmptyList) => Expr::List { + items: &[], + final_comments: &[], + }, Layout::Builtin(Builtin::List(_, elem_layout)) => { // Turn the (ptr, len) wrapper struct into actual ptr and len values. let len = unsafe { *(ptr.offset(env.ptr_bytes as isize) as *const usize) }; @@ -331,7 +337,10 @@ fn list_to_ast<'a>( let output = output.into_bump_slice(); - Expr::List(output) + Expr::List { + items: output, + final_comments: &[], + } } fn single_tag_union_to_ast<'a>( diff --git a/compiler/can/src/expr.rs b/compiler/can/src/expr.rs index cf1cc2d02b..777e51f599 100644 --- a/compiler/can/src/expr.rs +++ b/compiler/can/src/expr.rs @@ -285,7 +285,9 @@ pub fn canonicalize_expr<'a>( } } ast::Expr::Str(literal) => flatten_str_literal(env, var_store, scope, literal), - ast::Expr::List(loc_elems) => { + ast::Expr::List { + items: loc_elems, .. + } => { if loc_elems.is_empty() { ( List { diff --git a/compiler/can/src/operator.rs b/compiler/can/src/operator.rs index 0ec2c82f72..5f9d73bb70 100644 --- a/compiler/can/src/operator.rs +++ b/compiler/can/src/operator.rs @@ -109,14 +109,24 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located>) -> &'a arena.alloc(Located { region, value }) } - List(elems) | Nested(List(elems)) => { - let mut new_elems = Vec::with_capacity_in(elems.len(), arena); + List { + items, + final_comments, + } + | Nested(List { + items, + final_comments, + }) => { + let mut new_items = Vec::with_capacity_in(items.len(), arena); - for elem in elems.iter() { - new_elems.push(desugar_expr(arena, elem)); + for item in items.iter() { + new_items.push(desugar_expr(arena, item)); } - let new_elems = new_elems.into_bump_slice(); - let value: Expr<'a> = List(new_elems); + let new_items = new_items.into_bump_slice(); + let value: Expr<'a> = List { + items: new_items, + final_comments, + }; arena.alloc(Located { region: loc_expr.region, diff --git a/editor/src/expr.rs b/editor/src/expr.rs index 8cd7df43f8..1af1747c11 100644 --- a/editor/src/expr.rs +++ b/editor/src/expr.rs @@ -285,14 +285,14 @@ pub fn to_expr2<'a>( Str(literal) => flatten_str_literal(env, scope, &literal), - List(elements) => { + List { items, .. } => { let mut output = Output::default(); let output_ref = &mut output; - let elems = PoolVec::with_capacity(elements.len() as u32, env.pool); + let elems = PoolVec::with_capacity(items.len() as u32, env.pool); - for (node_id, element) in elems.iter_node_ids().zip(elements.iter()) { - let (expr, sub_output) = to_expr2(env, scope, &element.value, element.region); + for (node_id, item) in elems.iter_node_ids().zip(items.iter()) { + let (expr, sub_output) = to_expr2(env, scope, &item.value, item.region); output_ref.union(sub_output);