This commit is a follow-up to 123334881a.
Its purpose is to make the environments module abstract again,
by moving the parsing mechanism in its own module.
Consequently, the environments module can be linked earlier again (as
was the case before the commit mentionned above) and can thus be
used in other modules.
The previous implementation used global state and was making another
change more difficult than it had to be.
Note: I got rid of `rev_let_bound_idents` in the API because computing
it is no more efficient than `Fun.compose List.rev let_bound_idents`.
(Only the _full versions might have a more-efficient rev_ version,
and those are not exposed, which is the right choice:
a simpler API is worth a list reversal.)
This option allows to build self-contained bytecode executable and is aimed to replace `-custom`. The main difference between the two is that executables produced by `-output-compete-exe` can be stripped.
Thoses test should *not* be toplevel or expect-style tests, because
then the Obj.id counter of the compiler implementation (called by the
bytecode read-eval-print loop) is the same as the Obj.id counter of
the test code below. In particular, any change to the compiler
implementation to use more objects or exceptions will change the
reference numbers, making the test fragile in a very surprising way.
I found the issue while working on #8968, which hits the bug.
I tested this PR by adding a spurious
let exception Unused in
ignore Unused;
in typing/typecore.ml:unify_pat_types. Before this PR,
make one DIR=tests/typing-objects
would be broken by the change. After this PR,
make one DIR=tests/typing-objects
make one DIR=tests/runtime-objects
works fine.
(no change entry needed)
* Removed the function 'caml_init_alloc_from_heap' from memory.h, as well as it's definition in memory.c, and the calling code in gc_ctrl.c. The function was unconditionally returning zero with no other functionality, as explained in issue #8709.
No change entry needed.
The Tpat_exception case would make several calls to the continuation
'k', which must be used linearily -- exactly once.
This bug is harmless and hard to reach today because Tpat_exception is
mostly used at the toplevel or under an or-pattern, where the
continuation is the identity. But the type-checker still allows
Ppat_constraint and Ppat_open nodes above exception-patterns, allowing
to observe the duplication. And maybe more tomorrow?
$ ocaml -dsource
# fun f x -> match f x with _ -> () | (exception _ : exn) -> ();;
[...]
pattern
Tpat_constraint
core_type
Ttyp_constr "exn/7!"
[]
pattern
Tpat_exception
pattern
Tpat_constraint
core_type
Ttyp_constr "exn/7!"
[]
pattern
Tpat_any
[...]
# fun f x -> match f x with _ -> () | Stdlib.(exception _) -> ();;
[...]
pattern
Tpat_open ""Stdlib!""
pattern
Tpat_exception
pattern
Tpat_open ""Stdlib!""
pattern (//toplevel//[1,0+42]..//toplevel//[1,0+43])
Tpat_any
[...]