Skip to main content

active_setter_precondition_checks

Function active_setter_precondition_checks 

Source
fn active_setter_precondition_checks(
    setter: &ParsedMethod,
    impl_preconditions: Option<bool>,
) -> Vec<String>
Expand description

Build the precondition guard lines for the setter branch of a combined getter/setter active binding.

This is the same precondition block the standalone set_* method gets via crate::r_class_formatter::MethodContext::precondition_checks — the active-binding branch used to skip it (audit 2026-07-06 finding 4), so obj$prop <- "bad" bypassed the R-level type check the standalone setter enforces.

R6 active bindings always receive the assigned value through a formal named value, while the Rust setter’s parameter may have any name, so the first non-receiver parameter (the only one the binding forwards — see the .with_args(&["value"]) call site) is renamed to value before the checks are built, and a formal it declares (#1842) is dropped, since it names the set_* method’s argument. Any additional parameters are ignored: the binding never passes them, and checks referencing their names would error at runtime.

impl_preconditions is the impl block’s preconditions / no_preconditions; with the setter’s own spellings (the method’s, the parameter’s) the binding keeps or drops the type checks exactly when the set_* method does. The per-parameter decision moves to value with the rest of the parameter’s attributes, before the checks are resolved.