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.
This commit is contained in:
Tad Hardesty 2019-11-07 18:55:38 -08:00
parent 4742ca1c95
commit 7fc9ae2412

View file

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