I'm not a back-end specialist, so I cannot really comment on the proposed patch (except that I believe Record_regular should be Types.Record_regular, etc, unless you're already on the record_disambiguation branch!). But while trying to understand the general compilation strategy for recursive bindings, I found the following lines which I don't really understand:

Why do we do that, instead of simply calling "init_block rem" in the RHS_nonrec case? At least, this might allow to catch earlier this kind of bugs. Or are there cases where those dummy bindings are actually needed?

I have uploaded a better patch (provided by XL). I have committed it in the 4.00 branch, but not in trunk because we still need to decide whether/how to refactor this function to make it common to the byte-code and native back-ends.

Fixed in 4.00 (r 13110), but this PR stays open until we rework the code in the trunk.

Patch #2 was propagated to the trunk by one of Damien's big merges (commit r13699) then cloned in the 4.01 branch. So, all is as it should be. Refactoring can wait. I take the liberty of marking this PR as resolved.