From 6624983ae3e6ba02bb85ee9453b52ef746e836ad Mon Sep 17 00:00:00 2001 From: azur Date: Sat, 11 Mar 2023 01:18:45 +0700 Subject: [PATCH] make deepsource happy --- src/main.rs | 2 +- src/read/parse.rs | 2 +- src/trans/low.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 131da14..baa5696 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ fn main() { let ast = past.into_iter().map(|(e, _)| translate_stmt(e)).collect::>(); let js = ast.into_iter().map(translate_js_stmt).collect::>(); - let mut file = std::fs::File::create(opt.output.unwrap_or("out.js".into())) + let mut file = std::fs::File::create(opt.output.unwrap_or_else(|| "out.js".to_owned())) .expect("Failed to create file"); let s = js .into_iter() diff --git a/src/read/parse.rs b/src/read/parse.rs index 6a47f2c..b93fade 100644 --- a/src/read/parse.rs +++ b/src/read/parse.rs @@ -515,7 +515,7 @@ pub fn parse( ) -> (Option>>, Vec>) { let (ast, parse_error) = stmts_parser() .then_ignore(end()) - .parse_recovery(Stream::from_iter(len..len + 1, tokens.into_iter())); + .parse_recovery(Stream::from_iter(len..=len, tokens.into_iter())); (ast, parse_error) } \ No newline at end of file diff --git a/src/trans/low.rs b/src/trans/low.rs index d81f2c2..81ce92e 100644 --- a/src/trans/low.rs +++ b/src/trans/low.rs @@ -88,9 +88,9 @@ pub fn translate_expr(expr: PExpr) -> Expr { } expr } else { - Expr::Defines(vars.into_iter().map(|(name, _ty, val)| { + Expr::Defines(vars.into_iter().map(|(name, _ty, val)| (name, translate_expr(val.0)) - }).collect()) + ).collect()) } }, PExpr::If { cond, t, f } => Expr::If { @@ -190,9 +190,9 @@ pub fn translate_js_expr(expr: Expr) -> JSExpr { t: Box::new(translate_js_expr(*t)), f: Box::new(translate_js_expr(*f)), }, - Expr::Defines(defs) => JSExpr::Defines(defs.into_iter().map(|(name, val)| { + Expr::Defines(defs) => JSExpr::Defines(defs.into_iter().map(|(name, val)| (name, translate_js_expr(val)) - }).collect()), + ).collect()), Expr::Return(e) => JSExpr::Return(Box::new(translate_js_expr(*e))), } } \ No newline at end of file