pub struct Ctx {
pub env: Rc<Env>,
pub report: Report,
pub vars: HashMap<String, Ty>,
pub locals: HashSet<String>,
pub present: HashSet<String>,
pub nonnull: HashSet<String>,
pub const_memo: Rc<RefCell<HashMap<String, Ty>>>,
pub pos: Rc<RefCell<Option<Rc<Expr>>>>,
pub record: Option<Rc<dyn Fn(&Rc<Expr>, &Ty)>>,
pub resolve_hook: Option<Rc<dyn Fn(&Rc<Expr>, Option<Target>)>>,
pub binding: bool,
}Expand description
the inference context: the environment, the local variables, the narrowing guards in force, the reporter
Fields§
§env: Rc<Env>the environment names resolve in
report: Reportwhere findings go
vars: HashMap<String, Ty>the local variables in scope, with their types
locals: HashSet<String>the names bound by the expression itself — function and lambda parameters, comprehension variables, match bindings: they shadow a record’s members (§4.3)
present: HashSet<String>the paths a guard proved present
nonnull: HashSet<String>the paths a guard proved non-null
const_memo: Rc<RefCell<HashMap<String, Ty>>>the constants’ inferred types, memoized
pos: Rc<RefCell<Option<Rc<Expr>>>>the expression under inference (shared by child contexts): what a report is anchored to
record: Option<Rc<dyn Fn(&Rc<Expr>, &Ty)>>Phase 6 foundations: every inferred node’s type, and every name’s resolution (the language server’s tables)
resolve_hook: Option<Rc<dyn Fn(&Rc<Expr>, Option<Target>)>>called with every name’s resolution (the language server’s navigation)
binding: boolthe expression’s value is bound at evaluation — an output, an input’s fallback, a member’s default or derived expression, and every position inside a literal there: an object whose entries the static type does not fix is validated then, not rejected here (§3.18, D31 amended, v0.4.4)