From 7fc9ae241223e009665ccf84fddde7f4f070402e Mon Sep 17 00:00:00 2001 From: Tad Hardesty Date: Thu, 7 Nov 2019 18:55:38 -0800 Subject: [PATCH] Handle TRUE and FALSE constants in should_call_parent Broken during the change of TRUE and FALSE from macros to const vars, so the preprocessor doesn't transform them anymore and this argument isn't currently const-evalauted. Solved for now by handling the "TRUE" and "FALSE" idents specially. Fixes #106. --- src/dreamchecker/lib.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/dreamchecker/lib.rs b/src/dreamchecker/lib.rs index 16e7928b..955281b2 100644 --- a/src/dreamchecker/lib.rs +++ b/src/dreamchecker/lib.rs @@ -351,8 +351,18 @@ impl<'o> AnalyzeObjectTree<'o> { } } } else if name == "SpacemanDMM_should_call_parent" { - if let Some(Term::Int(i)) = value.as_term() { - self.must_call_parent.insert(proc, *i != 0); + // Maybe this should be using constant evaluation, but for now accept TRUE and FALSE directly. + match match value.as_term() { + Some(Term::Int(0)) => Some(false), + Some(Term::Int(1)) => Some(true), + Some(Term::Ident(i)) if i == "FALSE" => Some(false), + Some(Term::Ident(i)) if i == "TRUE" => Some(true), + _ => None, + } { + Some(value) => { self.must_call_parent.insert(proc, value); }, + None => error(statement.location, format!("invalid value for {}: {:?}", name, value)) + .set_severity(Severity::Warning) + .register(self.context) } } else if name.starts_with("SpacemanDMM_") { error(statement.location, format!("unknown linter setting {:?}", name))