From 71359d82aaa92e0dde3a011af06801a1e9696e6a Mon Sep 17 00:00:00 2001 From: mlokr Date: Fri, 19 Jul 2024 13:21:14 +0200 Subject: [PATCH] j --- hblang/src/parser.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hblang/src/parser.rs b/hblang/src/parser.rs index 43735f41..06483934 100644 --- a/hblang/src/parser.rs +++ b/hblang/src/parser.rs @@ -951,8 +951,8 @@ impl<'a> std::fmt::Display for Expr<'a> { write!(f, "{}(", Postfix(func))?; fmt_list(f, trailing_comma, ")", args, std::fmt::Display::fmt) } - Self::Return { val: Some(val), .. } => write!(f, "return {val};"), - Self::Return { val: None, .. } => write!(f, "return;"), + Self::Return { val: Some(val), .. } => write!(f, "return {val}"), + Self::Return { val: None, .. } => write!(f, "return"), Self::Ident { name, .. } => write!(f, "{name}"), Self::Block { stmts, .. } => { write!(f, "{{")?; @@ -963,7 +963,7 @@ impl<'a> std::fmt::Display for Expr<'a> { for _ in 0..INDENT.with(|i| i.get()) { write!(f, "\t")?; } - writeln!(f, "{stmt}")?; + writeln!(f, "{stmt};")?; } Ok(()) })(); @@ -989,15 +989,7 @@ impl<'a> std::fmt::Display for Expr<'a> { display_branch(f, left)?; write!(f, " {op} ")?; - display_branch(f, right)?; - - if matches!(op, TokenKind::Decl | TokenKind::Assign) - && !matches!(right, Self::Closure { .. }) - { - write!(f, ";")?; - } - - Ok(()) + display_branch(f, right) } } }