From 16bf166fa979904228b1e829c7302bca695f2660 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 5 Aug 2019 03:31:10 -0700 Subject: [PATCH] Fix bug with debug specifications --- schala-lang/language/src/schala.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/schala-lang/language/src/schala.rs b/schala-lang/language/src/schala.rs index b0260a1..6f4f5ff 100644 --- a/schala-lang/language/src/schala.rs +++ b/schala-lang/language/src/schala.rs @@ -238,22 +238,23 @@ impl ProgrammingLanguageInterface for Schala { let stage_names = stage_names(); let cur_stage_name = stage_names[n]; let ask = token.debug_requests.iter().find(|ask| ask.is_for_stage(cur_stage_name)); - let mut debug_artifact = ask.and_then(|ask| match ask { - DebugAsk::ByStage { token, .. } => token.as_ref(), - _ => None - }).map(|token| { - let parsing = if cur_stage_name != "parsing" { - None - } else { - Some(match &token[..] { + + let parsing = match ask { + Some(DebugAsk::ByStage { token, .. }) if cur_stage_name == "parsing" => Some( + token.as_ref().map(|token| match &token[..] { "compact" => ParsingDebugType::CompactAST, "expanded" => ParsingDebugType::ExpandedAST, "trace" => ParsingDebugType::Trace, _ => ParsingDebugType::CompactAST, - }) - }; - PassDebugArtifact { parsing, ..Default::default() } + }).unwrap_or(ParsingDebugType::CompactAST) + ), + _ => None, + }; + + let mut debug_artifact = ask.map(|_| PassDebugArtifact { + parsing, ..Default::default() }); + let output = func(input, token.schala, debug_artifact.as_mut()); token.stage_durations.push((cur_stage_name.to_string(), token.sw.elapsed()));