ocaml-flambda / flambda-backend

The Flambda backend project for OCaml
92 stars 65 forks source link

Rc_close_at_apply should only close the current region early #2736

Closed mshinwell closed 3 days ago

mshinwell commented 1 week ago

The test case here exhibits a problem relating to the handling of Rc_close_at_apply in Lambda_to_flambda. It was being misinterpreted as "close all regions up to those required by the return continuation" prior to the call -- whereas it should only affect the current region in this regard. I've added some explanations in lambda.mli which are almost entirely due to @stedolan (thanks also to Stephen for other assistance with this bug).

I'm going to think about how we can adjust the test case so it actually reliably fails prior to this PR, and succeeds after.

This patch needs looking over very carefully, as this is a subtle area.