cl-ast: Remove tail from let (it caused more problems that it could've solved)

This commit is contained in:
2024-07-31 03:19:20 -05:00
parent de63a8c123
commit 8675f91aca
8 changed files with 7 additions and 25 deletions

View File

@@ -402,7 +402,6 @@ pub struct Let {
pub name: Sym,
pub ty: Option<Box<Ty>>,
pub init: Option<Box<Expr>>,
pub tail: Option<Box<Expr>>,
}
/// An [Assign]ment expression: [`Expr`] ([`ModifyKind`] [`Expr`])\+

View File

@@ -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(())
}
}

View File

@@ -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 {

View File

@@ -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;