From 8675f91aca9b7fb5836c0864431cdee1e1647262 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 31 Jul 2024 03:19:20 -0500 Subject: [PATCH] cl-ast: Remove tail from let (it caused more problems that it could've solved) --- compiler/cl-ast/src/ast.rs | 1 - compiler/cl-ast/src/ast_impl.rs | 5 +---- compiler/cl-ast/src/ast_visitor/fold.rs | 3 +-- compiler/cl-ast/src/ast_visitor/visit.rs | 5 +---- compiler/cl-interpret/src/interpret.rs | 3 +-- compiler/cl-parser/src/parser.rs | 5 ----- compiler/cl-repl/examples/yaml.rs | 5 ++--- compiler/cl-typeck/src/stage/populate.rs | 5 +---- 8 files changed, 7 insertions(+), 25 deletions(-) diff --git a/compiler/cl-ast/src/ast.rs b/compiler/cl-ast/src/ast.rs index 39d9c71..b7275d0 100644 --- a/compiler/cl-ast/src/ast.rs +++ b/compiler/cl-ast/src/ast.rs @@ -402,7 +402,6 @@ pub struct Let { pub name: Sym, pub ty: Option>, pub init: Option>, - pub tail: Option>, } /// An [Assign]ment expression: [`Expr`] ([`ModifyKind`] [`Expr`])\+ diff --git a/compiler/cl-ast/src/ast_impl.rs b/compiler/cl-ast/src/ast_impl.rs index b5f1872..1e717bd 100644 --- a/compiler/cl-ast/src/ast_impl.rs +++ b/compiler/cl-ast/src/ast_impl.rs @@ -443,7 +443,7 @@ mod display { impl Display for Let { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let Self { mutable, name, ty, init, tail } = self; + let Self { mutable, name, ty, init } = self; write!(f, "let {mutable}{name}")?; if let Some(value) = ty { write!(f, ": {value}")?; @@ -451,9 +451,6 @@ mod display { if let Some(value) = init { write!(f, " = {value}")?; } - if let Some(value) = tail { - write!(f, ";\n{value}")?; - } Ok(()) } } diff --git a/compiler/cl-ast/src/ast_visitor/fold.rs b/compiler/cl-ast/src/ast_visitor/fold.rs index c784348..ce16d7d 100644 --- a/compiler/cl-ast/src/ast_visitor/fold.rs +++ b/compiler/cl-ast/src/ast_visitor/fold.rs @@ -227,13 +227,12 @@ pub trait Fold { s } fn fold_let(&mut self, l: Let) -> Let { - let Let { mutable, name, ty, init, tail } = l; + let Let { mutable, name, ty, init } = l; Let { mutable: self.fold_mutability(mutable), name: self.fold_sym(name), ty: ty.map(|t| Box::new(self.fold_ty(*t))), init: init.map(|e| Box::new(self.fold_expr(*e))), - tail: tail.map(|e| Box::new(self.fold_expr(*e))), } } fn fold_expr(&mut self, e: Expr) -> Expr { diff --git a/compiler/cl-ast/src/ast_visitor/visit.rs b/compiler/cl-ast/src/ast_visitor/visit.rs index 5926cd2..59754a8 100644 --- a/compiler/cl-ast/src/ast_visitor/visit.rs +++ b/compiler/cl-ast/src/ast_visitor/visit.rs @@ -192,7 +192,7 @@ pub trait Visit<'a>: Sized { } fn visit_semi(&mut self, _s: &'a Semi) {} fn visit_let(&mut self, l: &'a Let) { - let Let { mutable, name, ty, init, tail } = l; + let Let { mutable, name, ty, init } = l; self.visit_mutability(mutable); self.visit_sym(name); if let Some(ty) = ty { @@ -201,9 +201,6 @@ pub trait Visit<'a>: Sized { if let Some(init) = init { self.visit_expr(init) } - if let Some(tail) = tail { - self.visit_expr(tail) - } } fn visit_expr(&mut self, e: &'a Expr) { let Expr { extents, kind } = e; diff --git a/compiler/cl-interpret/src/interpret.rs b/compiler/cl-interpret/src/interpret.rs index a007ecb..69a1819 100644 --- a/compiler/cl-interpret/src/interpret.rs +++ b/compiler/cl-interpret/src/interpret.rs @@ -116,10 +116,9 @@ impl Interpret for Stmt { } impl Interpret for Let { fn interpret(&self, env: &mut Environment) -> IResult { - let Let { mutable: _, name, ty: _, init, tail } = self; + let Let { mutable: _, name, ty: _, init } = self; let init = init.as_ref().map(|i| i.interpret(env)).transpose()?; env.insert(*name, init); - tail.as_ref().map(|e| e.interpret(env)).transpose()?; Ok(ConValue::Empty) } } diff --git a/compiler/cl-parser/src/parser.rs b/compiler/cl-parser/src/parser.rs index 79b715f..afe86fe 100644 --- a/compiler/cl-parser/src/parser.rs +++ b/compiler/cl-parser/src/parser.rs @@ -916,11 +916,6 @@ impl Parse<'_> for Let { } else { None }, - tail: if p.match_type(TokenKind::Semi, Parsing::Let).is_ok() { - Some(Expr::parse(p)?.into()) - } else { - None - }, }) } } diff --git a/compiler/cl-repl/examples/yaml.rs b/compiler/cl-repl/examples/yaml.rs index 44dae41..6169f64 100644 --- a/compiler/cl-repl/examples/yaml.rs +++ b/compiler/cl-repl/examples/yaml.rs @@ -371,13 +371,12 @@ pub mod yamlify { } impl Yamlify for Let { fn yaml(&self, y: &mut Yamler) { - let Self { mutable, name, ty, init, tail } = self; + let Self { mutable, name, ty, init } = self; y.key("Let") .pair("name", name) .yaml(mutable) .pair("ty", ty) - .pair("init", init) - .pair("tail", tail); + .pair("init", init); } } impl Yamlify for Expr { diff --git a/compiler/cl-typeck/src/stage/populate.rs b/compiler/cl-typeck/src/stage/populate.rs index c1f6827..0947d18 100644 --- a/compiler/cl-typeck/src/stage/populate.rs +++ b/compiler/cl-typeck/src/stage/populate.rs @@ -146,7 +146,7 @@ impl<'a> Visit<'a> for Populator<'_, 'a> { } fn visit_let(&mut self, l: &'a cl_ast::Let) { - let cl_ast::Let { mutable, name, ty, init, tail } = l; + let cl_ast::Let { mutable, name, ty, init } = l; let mut entry = self.new_entry(NodeKind::Local); entry.inner.set_source(Source::Local(l)); @@ -159,9 +159,6 @@ impl<'a> Visit<'a> for Populator<'_, 'a> { if let Some(init) = init { entry.visit_expr(init) } - if let Some(tail) = tail { - entry.visit_expr(tail) - } let child = entry.inner.id(); self.inner.add_child(*name, child);