Skip to main content

FUNCTIONAL_LIST_METHODS

Constant FUNCTIONAL_LIST_METHODS 

Source
pub const FUNCTIONAL_LIST_METHODS: &[&str];
Expand description

The functional List built-in methods that take a closure argument and must be lowered to each target’s native iteration idiom (see desugared_list_functional_method).

These resolve in the checker to a concrete return type with a fully typed closure parameter (see resolve_builtin_method_fn_type for List), but the receiver type List[T] has no .map/.filter/.reduce/… method in any target — JS/TS arrays have .map/.filter/.reduce but not the desugared recv.map(recv, cb) shape; Python lists, Rust Vec, and Go slices have no such methods at all. Without a dedicated lowering these fall through to the generic desugared-self-call path, which emits recv.map(recv, cb) — array-not-a-callback on TS, “x.map is not a function” on JS, 'list' object has no attribute 'map' on Python, no method 'map' for Vec on Rust, and a keyword/selector parse error on Go (map is reserved). This is the surface counterpart to the core.iter free functions (map/filter/fold/… over ListIterator[T]), which already lower correctly.

The set mirrors the closure-taking List methods the checker resolves: map/filter/reduce/fold/for_each/find/any/all/flat_map. The no-closure functional combinators (take/skip/reverse/sort/dedup/ enumerate/zip/flatten/to_set/push/pop/…) are intentionally NOT in this set: they are either non-closure transforms or mutating methods left to their existing paths (DQ18).