pub fn typecheck(
expr: &Expr,
expected: Option<&Type>,
coerce_top_string: bool,
) -> Result<Expr, ParseError>Expand description
Statically type-check a parsed expression, optionally against the type a
property expects. On success returns a rewritten tree with type-directed
coercion/assertion nodes inserted (evaluate this returned expression so the
coercions take effect). Returns a ParseError for expressions the
reference implementation rejects at compile time (bad comparisons, malformed
match branches, non-interpolatable outputs, misused zoom, and so on).
coerce_top_string reflects whether the target property is string-typed
(not merely enum-typed): such properties coerce the top-level result to a
string rather than asserting it.