Skip to main content

active_setter_precondition_checks

Function active_setter_precondition_checks 

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

Build the stopifnot() precondition 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. Any additional parameters are ignored: the binding never passes them, and checks referencing their names would error at runtime.