Semantic Diff

#9286 Visit an arrow's argument types without a closure

1 commit

70da3d1bc43caa96214c942f72db9296f83a9db6..pr-9286

c63c67ad7 · JonoPrest · Nov 09, 2026, 14:40 UTC

Visit an arrow's argument types without a closure

Why

iter_type_expr visited the argument types of a Tarrow with List.iter (fun {typ} -> f typ), which allocates a closure each time it reaches an arrow type. Many walks over types go through it (copying, marking, levels, occur checks), and function types are common.

The arguments are now visited by a recursive function that takes f. The order of the visits is unchanged.

Measured with scripts/compilerBenchmarks.js against the previous commit: allocated words -0.22% in total (-0.20% for the files compiled one by one, -0.24% in the builds of tests/tests), stress/NestedClosures.res -0.89%. On a 552 module React app (clean build, one domain) the build allocates 0.18% fewer words.