Commit Graph

2774 Commits (master)

Author SHA1 Message Date
Jacques Garrigue 6ccab9b9b0 Fix #9695: no error when opening an alias to a missing module 2020-06-23 15:31:45 +02:00
Xavier Leroy 40a55c71a1 Is_in_static_data is not available in no-naked-pointers mode
This is another classification macro that requires the page table.
Its only uses in the whole OPAM universe is two of our own tests
(tests/asmcomp/is_static.ml and tests/lib-obj/reachable_words_np.ml)
which are now run only in naked-pointers mode.
2020-06-23 10:30:40 +02:00
Xavier Leroy ccb7829ddc Revise testing of Obj.reachable_words
Part of the test makes sense only if the runtime system supports
naked pointers and has a page table to distinguish major heap pointers
from out-of-heap pointers.

This part is split off in a new test, lib-obj/reachable_words_np.ml,
conditionalized on "naked_pointers".
2020-06-22 19:37:22 +02:00
Jacques Garrigue 603506aa34
Add injectivity annotations (#9500) 2020-06-15 13:51:50 +02:00
Jacques Garrigue 24d087325c
Fix #7902: Type-checker infers a recursive type, even though -rectype… (#9556) 2020-06-15 10:26:26 +02:00
Xavier Leroy 400fe3f3a2
Merge pull request #9675 from xavierleroy/no-static-alloc
Remove the caml_static_{alloc,free,resize} primitives, which are unused and incompatible with no-naked-pointers mode.
2020-06-14 11:48:20 +02:00
Nicolás Ojeda Bär 33416d11db
Merge pull request #9469 from lpw25/fix-lazy-backtraces
Better backtraces for lazy values
2020-06-14 11:34:04 +02:00
Leo White 62e286a1c7 Fix unused functor argument warning in toplevel 2020-06-14 08:38:03 +01:00
Leo White b0e1540ac1 Fix missing unused variables warning with functor application 2020-06-14 08:38:03 +01:00
Leo White 1c03659e34 Add another test for usage warnings 2020-06-14 08:38:03 +01:00
Leo White 81902098b6 Fix incorrect copy_scopes in Subst 2020-06-14 08:30:33 +01:00
Leo White 080604989f Add regression tests 2020-06-14 08:25:41 +01:00
Leo White a02707c610 Better backtraces for lazy values 2020-06-14 07:57:35 +01:00
Leo White 9895b28d25 Add tests for backtraces from forcing lazy values 2020-06-14 07:51:31 +01:00
Xavier Leroy b0cd12d1c4 Test intext.ml: do not use the caml_static_alloc primitive
This primitive (from runtime/obj.c) is being phased out because
it returns a naked pointer outside the OCaml heap.

Instead, for the test, use a statically-allocated buffer
that is never visible from OCaml.
2020-06-13 11:39:02 +02:00
Gabriel Scherer c24198550a
Merge pull request #9612 from garrigue/pr6744ex
fix number and add examples for #6744
2020-06-10 14:05:31 +02:00
Nicolás Ojeda Bär 990bc3c892
Merge pull request #9633 from nojb/ocamltest_env_fix
ocamltest: do not overwrite user-defined variables
2020-06-08 13:17:38 +02:00
Gabriel Scherer a3b66f1b32 Parmatch.exhaust: single-row optimization
(See testsuite and code comments for an explanation.)
2020-06-07 08:03:57 +02:00
Gabriel Scherer 06cabea1df
Merge pull request #9608 from trefis/rematch-flattening
pattern-matching refactoring: clarify usage of the Cannot_flatten exception
2020-06-06 21:58:33 +02:00
Thomas Refis 30bb39d7d8 matching: add a test for do_for_multiple_match flattening failure
Note: this is due to mk_alpha_env raising Cannot_flatten during
splitting/precompilation.
2020-06-06 18:46:34 +02:00
Gabriel Scherer 63eb3dad0d Arg: a new Rest_all spec, similar to Rest, that passes all arguments at once
In particular this allow to detect a Rest_all keyword followed by no
arguments at all (an empty list).
2020-06-05 22:06:21 +02:00
Gabriel Scherer 357d624992
Merge pull request #9642 from garrigue/fix9640
Fix #9640: regression introduced by #9623
2020-06-05 21:10:55 +02:00
Xavier Leroy e57785524b Restrict 'test_locations' to 64-bit archs and update expected outputs
Expected outputs contain integer values for the "closure info"
field of some closures.  These values differ in 32 and 64 bits,
since the arity is stored in top 8 bits.  This test would need
different expected outputs for 32- and 64-bit platforms.

To keep things simple, this commit restricts the test
to only run on 64-bit platforms.  Since this changes the locations
2020-06-05 17:48:19 +02:00
Jacques Garrigue b2b9fc3d9a add example 2020-06-05 15:05:48 +02:00
Jacques Garrigue a96a610a95 Fix #9640: regression introduced by #9623 2020-06-05 14:56:51 +02:00
Nicolás Ojeda Bär d8d38752f9 Adapt tests 2020-06-05 07:40:17 +02:00
Gabriel Scherer 84c87bb8f1
Merge pull request #9623 from gasche/unboxed-merge-constraint
fix an environment problem in merge_constraint
2020-06-04 13:16:27 +02:00
Jacques Garrigue abb8db459d
Fix #7520: Odd behaviour of refutation cases with polymorphic variants (#9547) 2020-06-03 17:47:12 +02:00
Jacques Garrigue 13a081b04e
Fix #7741: Failure to report escaping type variable (#9545) 2020-06-03 17:31:38 +02:00
Gabriel Scherer 8b2f64c2ce Typemod.merge_constraint: fix computation of the signature environment
(suggested by Leo White and Jacques Garrigue)
2020-06-03 14:33:55 +02:00
Gabriel Scherer 7068266b32 Typemod.merge_constraint: be careful about the typing environments
This PR fixes an old bug in the interaction between [merge_constraint]
and [Typedecl.transl_with_constraint], where
variance (and now separability) are recomputed in an invalid type
environment. See #9624 and the new tests.
2020-06-03 14:33:50 +02:00
Gabriel Scherer 45248a7602 add a testcase for 'with type <lhs> = <rhs>' scoping 2020-06-03 14:33:12 +02:00
Jacques Garrigue ee20f5e648
Fix the polymorphic recursion problem of #9603 (#9617) 2020-06-02 22:05:30 +02:00
Stephen Dolan fd1bb255e1 More partial application warnings 2020-06-02 12:11:41 +01:00
Stephen Dolan 0d44a6cfe6 Remove Const_pointer from Lambda and Clambda (#9585)
Lambda and Clambda distinguish Const_int from Const_pointer only so
that they can pass the information to Cmm. But now that that
Const_pointer is gone from Cmm (#9578), there's no need for the
distinction in Lambda either.

This PR requires a bootstrap, because the .cmo format changes:
Lambda.structured_constant has one fewer constructor.  The bootstrap
is in the following commit.
2020-06-02 11:19:20 +02:00
Gabriel Scherer 5c9d5db728
Merge pull request #9511 from gasche/parmatch-exhaust-lazy
Parmatch: make `exhaust` (exhaustivity and fragility checking) lazy
2020-05-30 19:01:38 +02:00
Gabriel Scherer d8acfa92e4 parmatch: ensure specialized submatrices are in source order
We produce exhaustivity counter-example in the order of the
specialized submatrices. Having submatrices in source order gives the
nice behavior that the clause that would naturally been inserted first
in the source is given first as a counter-example.

Consider for example:

    function
    | true, true -> true
    | false, false -> false

The two counter-examples are (true, false) and (false, true).

Before this patch, (false, true) would be shown first.
After this patch, (true, false) is shown first.
This corresponds to the following natural completion order:

    function
    | true, true -> true
    | true, false -> ?
    | false, false -> false
    | false, true -> ?

On the other hand, the ordering of the default submatrix, with respect
to the specialized submatrices, is not preserved -- it is always
ordered last.
One could intuitively expect the default submatrix to appear in the
position of the first omega row in the source. We tried this, and
it is not a good idea:
- the change is much more invasive as the interface of
  `build_specialized_submatrices` has to change
- the behavior of the result is in fact unpleasant; it is not
  intuitive to order counter-examples in this way.

For example, consider:

    function
    | _, None -> false
    | true, Some true -> false

The two exhaustivity counter-examples are (true, Some false)
and (false, Some _). The second comes from the default submatrix:
morally it is (_, Some _), with "some other constructor missing from
the column" instead of the first _. There is no reason to suppose that
the user would want to place this (_, Some _) or (false, Some _)
counter-example first in the completed code; indeed, this intuition
would suggest writing an exhaustive covering of patterns of the
form (_, foo), inserted after the first clause, but then the other
clauses below become unnecessary!

When an omega patterns appears high in the column like this, it is
usually because there is a very specific matching condition to the
rest of its row, that justifies some shortcutting behavior. The
program is typically *not* completed by adding more specific matching
conditions.
2020-05-30 17:11:54 +02:00
Gabriel Scherer a8adec16f1 add regression tests for fragile-matching stack overflows 2020-05-30 17:10:37 +02:00
Gabriel Scherer 8f71174eb2 parmatch: make 'exhaust' lazy by returning a Seq.t
This solves exponential-blowup issue with the strict traversal and/or
strict witness computation in cases where an exponential number of
counter-examples is generated. This fixes Stack Overflow and
exponential-time issues on examples using or-patterns heavily,
including one that naturally found its way in real-world user
code (see the following testsuite commit).

We now systematically keep only one counter-example, instead of
letting the type-checker decide whether to discard
counter-examples (in Backtrack_or mode) or to preserve
them (in Refine_or mode).

Note: in the exhaustivity warning, there are sub-messages printed to
indicate that:

- the exhaustivity counter-example is related to an extensible type, or
- that a when-guarded clause does match the counter-example

In both cases the warning is there to explain the counter-example(s)
shown (not a property of all counter-examples); keeping at most one
valid counter-example means that they will be printed less often, but
it is the correct/intended behavior in that case.
2020-05-30 17:10:37 +02:00
Etienne Millon 71e91123c2
Attach package type attributes to core_type (#9615) 2020-05-29 14:29:10 +02:00
Gabriel Scherer 62dcc6e50d
Merge pull request #9613 from gretay-js/fix_compare
Bind arguments of integer and float compare in cmmgen
2020-05-28 13:47:18 +02:00
Gabriel Scherer 9b1bfc3b7c typedecl: correct update separability in transl_with_constraint
fixes #9607
2020-05-27 21:32:36 +02:00
Greta Yorsh 4c25ffcce9 Add a test 2020-05-27 16:59:45 +01:00
Jacques Garrigue e0524b535b fix number and add examples for #6744 2020-05-27 16:28:53 +02:00
Gabriel Scherer 463f1e1b9f add a testsuite case for an [@@unboxed] bug (#9607) reported by Stephen Dolan
Currently the test fails while it should work.
2020-05-27 10:38:09 +02:00
Gabriel Scherer 0c60f27978 remove an unused test reference file 2020-05-27 10:38:09 +02:00
Jacques Garrigue 1bb388bd15
Fix PR#7817: Unsound inclusion check for polymorphic variant (#9546) 2020-05-25 19:12:09 +02:00
Stephen Dolan 9e09fde735
Avoid creating ill-formed blocks in Cmm letrec (#9577)
Use "1" (integer 0) as filler value instead of "0" (null pointer).

Fixes: 7718
2020-05-25 10:11:45 +02:00
Xavier Leroy 89beb4c7f0 Use Sys.command instead of Unix.system to call 'cmp'
Clang's thread sanitizer TSAN reports a (false?) alarm on Unix.system
in multithreaded programs now that Unix.system is implemented
on top of posix_spawn.

This commit replaces Unix.system with Sys.command, which might work
better with TSAN, based on preliminary experiments.

Note that this test is about file I/O, not Unix.system, so the replacement
is acceptable.  In parallel, we need to understand what's happening
with TSAN and posix_spawn.
2020-05-20 19:49:36 +02:00
Stephen Dolan ff6ae43184
Merge pull request #9458 from jhjourdan/memprof_fatal_error_thread_exit
Memprof: fatal error if thread is stopped from a callback.
2020-05-20 16:58:10 +01:00
Xavier Leroy 565c07ceb0 Test redirection of stdout and stderr to the same file descriptor 2020-05-19 19:21:18 +02:00
Stephen Dolan 2d92955749
Remove Const_pointer (#9578)
Since #9316 was merged, Cconst_pointer is compiled in exactly the same way as Cconst_int. This commit removes the now-redundant Cconst_pointer and Cconst_natpointer.
2020-05-19 15:31:08 +02:00
Florian Angeletti faec2de1d6
Merge pull request #9566 from Octachron/testsuite_aliases_and_applicative_functors
tests: aliases and applicative functors
2020-05-18 10:57:29 +02:00
Gabriel Scherer c544d640b6 fix the testsuite (and add -dno-unique-ids where reasonable) 2020-05-16 17:51:54 +02:00
Gabriel Scherer 04d9c425f3 stdlib: provide a sequential interface of the Atomic module from OCaml Multicore
This module provides a purely sequential implementation of the
concurrent atomic references provided by the Multicore OCaml
standard library:

https://github.com/ocaml-multicore/ocaml-multicore/blob/parallel_minor_gc/stdlib/atomic.mli

This sequential implementation is provided in the interest of
compatibility: when people will start writing code to run on
Multicore, it would be nice if their use of Atomic was
backward-compatible with older versions of OCaml without having to
import additional compatibility layers. *)
2020-05-16 17:51:54 +02:00
Sébastien Briais f52fdc2068
Define to_rev_seq in Set and Map module (#9075) 2020-05-15 17:38:45 +02:00
octachron c991225652 tests: aliases and applicative functors
* Enable the full test for 3476
* add the 5058 example
2020-05-15 11:02:05 +02:00
Xavier Leroy 914dd057b5
win32unix: quote the arguments to the Unix.exec* functions (#9550)
Otherwise, arguments get split at spaces.
This is the same quoting that the Win32 implementation of
Unix.create_process does.

A test was added.

Fixes: 9320
2020-05-14 18:15:10 +02:00
Nicolás Ojeda Bär f3e6d27e30 Add test 2020-05-13 20:57:21 +02:00
Gabriel Scherer f81e2b6a59
testsuite: remove a slow exhaustiveness check (#9555)
The test takes 14s to run every time we run the checksuite, and it
does not seem to serve an easily identifiable purpose. In theory
similar tests could help detect a performance regression in
exhaustiveness checking, but this test seems to only degrade in
constant factor (#9152 proposed to use ocamlc.opt instead of ocamlc to
run it, but it was declined as "hiding" potential problems, which
suggests constant-factor differences). We do not monitor the testsuite
for 10s timing difference, so it is unlikely that we would notice
a constant-factor difference during automated testing.
2020-05-13 10:52:56 +02:00
Jacques-Henri Jourdan 629fae6dc4 Add test statmemprof/thread_exit_in_callback. 2020-05-11 17:10:13 +02:00
Gabriel Scherer f7ec223df9 add a known-bug test for buggy 'rec' (non)use in the #show command 2020-05-09 08:43:23 +02:00
Gabriel Scherer 3a43b84e8a compare: correctly compare a Closure_tag with an Infix_tag 2020-05-06 22:29:01 +02:00
KC Sivaramakrishnan 9355b4e8f5
Initialise in caml_obj_block / Obj.new_block only when necessary (#9513)
caml_alloc returns initialised blocks for tag < No_scan_tag. Otherwise,
initialise the blocks as necessary.

For Abtract_tag, Double_tag and Double_array_tag, the initial contents
are irrelevant.

Uninitialised Custom_tag objects are difficult to use correctly. Hence,
reject custom block allocations through Obj.new_block.

For String_tag, the last byte encodes the string length. Hence, reject
zero-length string objects. Initialise the last byte which encodes the
length to ensure non-negative lengths for uninitialised strings.
2020-05-02 18:47:16 +02:00
Nicolás Ojeda Bär e20736dda0
unboxed-primitive-args: test does not require unix (#9517) 2020-04-30 18:26:24 +02:00
David Allsopp 42b8c20cce Fix instrumented-runtime test on OpenBSD 2020-04-30 15:52:50 +01:00
Enguerrand Decorne b7f0494df5 Rewrite the instrumented runtime to store traces in the CTF format.
The instrumentation code in the instrumented runtime was replaced
with new APIs to gather runtime statistics and output them in a new format
(Common Trace Format).
This commit also exposes new functions in the Gc module to pause or resume
instrumentation during a program execution (Gc.eventlog_pause and
Gc.eventlog_resume).
2020-04-30 10:32:01 +02:00
Jeremy Yallop 2e30946419
Support marshalling of bigarrays with dimensions that don't fit in 4 bytes (#8791)
Use a variable-length encoding (suggested by @stedolan) for dimensions that supports dimensions up to 2^64-1 each.

Change the marshalling identifier for bigarrays:_bigarray ~> _bigarr02
The identifier change reflects a change in the bigarray marshalling format.
2020-04-29 18:51:01 +02:00
Stephen Dolan 6923fd1590
fix module_coercion test on no-flat-floatarray mode (#9508) 2020-04-28 17:32:49 +01:00
Jacques-Henri Jourdan 90871480d9 Fix statmemprof/callstacks.ml when --disable-flat-float-array is used.
We do this by using a specific reference file in the case this option is used.
2020-04-27 19:14:55 +02:00
Jacques-Henri Jourdan 687076d662 Remove redundancy in testsuite/tests/statmemprof/comballoc.ml 2020-04-27 18:45:16 +02:00
Stephen Dolan b7716c4625 Update testsuite with new backtrace format, and add test for names 2020-04-27 12:58:53 +01:00
Stephen Dolan 2986beaa78 Replace Location.t with Lambda.scoped_location in Lambda code
This commit threads scopes through translation from Typedtree to
Lambda, extending the scopes when entering functions, modules,
classes and methods.
2020-04-27 12:58:53 +01:00
Nicolás Ojeda Bär 1e98c52e93
Link std_exit.cmo into binaries compiled with -output-complete-exe (#9495) 2020-04-25 13:01:03 +02:00
Mark Shinwell df20ccf838 Fix recursive module initialisation that does not terminate (#9497)
This fixes the bug reported in issue 9494 and adds a test case.

Closes: #9494 
(cherry picked from commit ff98901d11fb01ba224772c402763df20d246635)
2020-04-24 17:50:19 +02:00
Nicolás Ojeda Bär 8f3833c4d0
Add RISC-V native-code backend (#9441)
This is a port of ocamlopt for the RISC-V processor in 64-bit mode.
2020-04-24 16:04:50 +02:00
madroach 82700678b2
Don't include stdio.h in caml/misc.h (#9483)
* Don't include stdio.h in caml/misc.h
There is no need to include stdio.h in caml/misc.h
This seems to have happened by accident in commit cddec18fde
On OpenBSD, stderr and stdout are macros defined in stdio.h
ppx_expect uses stderr and stdout as identifiers in
collector/expect_test_collector_stubs.c where caml/misc.h is included.
This confuses the C compiler, because the macro will get expanded where an identifier is expected.

* Remove fallback NULL definition in caml/misc.h

ISO C guarantees that NULL is defined in <stddef.h>

* include missing stdio in tests/compatibility/stub.c
2020-04-24 14:27:32 +02:00
Leo White 2a50fef1ae
Merge pull request #9415 from lpw25/fix-open-struct-in-flambda-toplevel
Treat `open struct` as `include struct` in toplevel
2020-04-23 14:00:24 +01:00
Leo White 2ea16f6a8e Treat `open struct` as `include struct` in toplevel 2020-04-23 10:51:44 +01:00
Thomas Refis 9f49a71e90
Add forgotten substitution when compiling anonymous modules (#9477)
Fixes #9375
2020-04-23 10:55:40 +02:00
David Allsopp d732593c85 Test for linking archives with no modules 2020-04-22 14:17:29 +01:00
David Allsopp f4dc3003d5
Merge pull request #9457 from dra27/fix-mod_use
Fix #mod_use in toplevel
2020-04-20 16:13:26 +01:00
Florian Angeletti c5a1f91900
Merge pull request #9345 from Octachron/reproducible_env
Reproducible env summaries
2020-04-20 14:20:57 +02:00
Gabriel Scherer 702e34fbe5
Merge pull request #9463 from lthls/fix_int64_cmm_typ
Fix Cmm type of unboxed integers in Clet_mut
2020-04-20 11:34:15 +02:00
Florian Angeletti c041b0389e env summary: don't record implicit cmi files
We don't want to record the state of the file system at the start
of the compilation in the compiled files.
Consequently, we only add persistent modules to the env summary
if they have an observable action on the initial environment.
This is only the case if they shadow a non-persistent module of the
initially opened library (which can only be Stdlib currently).
2020-04-20 10:13:20 +02:00
Nicolás Ojeda Bär 91bbdac1f5
Fix asmcomp unit name test for bsd (#9473) 2020-04-19 17:53:57 +02:00
Nicolás Ojeda Bär ec6690fb53
x86 asm: handle unit names with special characters (#9465) 2020-04-19 11:17:00 +02:00
Gabriel Scherer 5722f78e31 add a regression test for issue 9460
See <https://github.com/ocaml/ocaml/issues/9460>.
We currently expect this test to fail on 32bit systems, and succeed on 64bits systems.

Contributed by Richard Jones.
2020-04-18 11:39:25 +02:00
Thomas Refis e01966a8b1 illegal commutation: more information in error message 2020-04-18 11:09:32 +02:00
Thomas Refis 384aa215fa optional arguments eliminated only when followed by unlabelled argument 2020-04-18 11:09:32 +02:00
Thomas Refis 9e0515f554 type_args: forbid optional arguments commuting when [ignore_labels=true] 2020-04-18 11:01:52 +02:00
Thomas Refis 2b1e211df9 type_application: merge sargs and more_sargs 2020-04-18 11:01:52 +02:00
Thomas Refis 046da6cd2e testsuite: -nolabels, commutes now, might get eliminated later 2020-04-18 11:01:52 +02:00
Thomas Refis 245a071938 testsuite: -nolabels and commuting optional arguments 2020-04-18 11:01:52 +02:00
Leo White a40889d6d9
Merge pull request #9393 from lpw25/improve-recmodule-usage-warnings
Improve recursive module usage warnings
2020-04-18 09:11:22 +01:00
Leo White 5f16c55316 Improve usage warnings for recursive modules 2020-04-18 08:08:54 +01:00
Leo White dd8218f8aa Add test for usage warnings of recursive modules 2020-04-18 08:08:54 +01:00
Leo White 8dcdda9674 Prohibit signature local types with constraints 2020-04-18 07:54:12 +01:00
Leo White 17257491b8 Add regression test 2020-04-18 07:54:12 +01:00
David Allsopp 528bd78c25 Add a test for #mod_use 2020-04-17 16:28:20 +01:00
Florian Angeletti 9108648867
Merge pull request #9409 from Octachron/yet_another_implicit_deps_error
packed modtype lookup can fail due to missing cmi
2020-04-17 16:28:19 +02:00
octachron 35dbd85b3e packed modtype lookup can fail due to missing cmi
This commit removes an assert false and makes the missing
cmi case behaves like the abstract case.
2020-04-17 11:22:38 +02:00
Leo White 59fac074fe
Merge pull request #9349 from lpw25/inline-hint
Add [@inlined hint] attribute
2020-04-17 08:27:58 +01:00
Leo White f46abe1916 Add [@inlined hint] attribute 2020-04-16 15:58:03 +01:00
Stephen Dolan 2208a4cbe6
Fix tail-call optimisation with a mutable ref (#9443)
Fix tail-call optimisation with a mutable ref
(Clet_mutable was not recognized properly in tail position.)

Add a test for tail-call optimisation with a mutable ref
2020-04-13 18:20:56 +02:00
Jacques Garrigue d67c704c4d
In `{expr with ...}`, always evaluate `expr` even if all labels are redefined (#9432)
This commit reverts c1a7ace (originally c545e04), which was a
temporary fix that is no longer needed because it was superseded by
#6608.

The temporary fix caused `{expr with lbl1 = e1; ... }` to not evaluate
`expr` if all labels of its type are overriden.  As reported in #7696
this is not desirable.  Reverting the temporary fix causes `expr` to
be evaluated always.

As a consequence, a corner case of value "let rec" is no longer accepted.
The corresponding test was updated.

Closes: #7696
2020-04-08 18:58:43 +02:00
Gabriel Scherer 7612a6d9b1 [minor] fix a Makefile warning by defining undefined variables
Report by Xavier Leroy:
  https://github.com/ocaml/ocaml/pull/9414#issuecomment-610231289
2020-04-07 15:06:12 +02:00
Florian Angeletti abda688b03
Merge pull request #1706 from Octachron/extension_disambiguated_bis
Spellchecker hints and type-directed disambiguation for extensible variants: bis
2020-04-06 11:28:37 +02:00
octachron 4f9f41e73a disambiguation for extension constructors
This commit exposes all extension constructors when looking up for
a construction with a given type in the environment.

This makes constructor disambiguation work for extension constructors.

Going one step further, when the name of an extension constructors
is misspelled, we cannot rely on the type to find all possible
names. However, since we are in an error path, we have some
path at hand.
Thus, this commit alters the "lookup_from_type" function in the
Constructor module to make it scan the whole environment for
extension constructors with the right type.

This commit should not change anything for labels and standard constructors.
2020-04-03 16:05:23 +02:00
Gabriel Scherer 1d76e2ca91
Merge pull request #9365 from gasche/Set-Map-filter_map
Map.filter_map and Set.filter_map
2020-04-02 17:59:51 +02:00
Gabriel Scherer 45697b3583 testsuite/Makefile: allow users to explicit set KEEP_TEST_DIR_ON_SUCCESS=1 2020-04-02 16:19:36 +02:00
Gabriel Scherer 89b41c3219 testsuite/Makefile: refactor the -promote ocamltest logic
The existing approach requires to set all ocamltest flags at once on
recursive calls. This is very inconvenient if we want to set more than
one flag -- we wish to support choosing both -promote
and -keep-test-dir-on-success.
2020-04-02 16:07:20 +02:00
Gabriel Scherer 017d4a3ead
Merge pull request #9254 from gasche/memprof-record
Gc.Memprof.start: take a record instead of 5 optional parameters
2020-04-02 02:27:55 +02:00
Gabriel Scherer ff6b20098f Gc.Memprof.start: take a record instead of 5 optional parameters
The Gc.Memprof module provides a low-level API, that will hopefully be
paired with user libraries that provide high-level instrumentation
choices.

A natural question is: how are the higher-level API going to expose
their choice of instrumentation to their users? With the current
Memprof.start API (before this patch), they would have to either
provide their own `start` function wrapping Memprof.start, or provide
a tuple of callbacks for to their users to pass to Memprof.start
themselves.

    val start : params -> unit
    (* or *)
    val callback : params ->
      ((allocation -> foo option) * (allocation -> bar option) * ... )

With an explicit record, it is easier for libraries to expose an
instrumentation choice (possibility parametrized over
user-provided settings):

    val tracker : params -> (foo, bar) Gc.Memprof.tracker

In addition, providing a record instead of optional parameters makes
it much easier to provide "default settings" (helper functions) that
instantiates the types `'minor` and `'ḿajor`, see for example
`simple_tracker` in this patch (which stores the same information for
the minor and major heap, and does not observe promotion), or to later
define checking predicates that can verify that a given choice of
callbacks is sensible (for example: providing a major-dealloc callback
but no promotion callback (dropping all tracked value on promotion) is
probably not a good idea).

Bootstrap: to avoid requiring an awkward bootstrap, this commit keeps
the (now unused) function caml_memprof_start_byt unchanged -- it is
used in the bootstrap binaries, so removing it would break the
build. The intention is to remove it in the following commit.
2020-04-01 16:37:28 +02:00
Thomas Refis 1e78d1e10c
add more principality warnings examples for applications (#9408) 2020-04-01 10:30:30 +02:00
Gabriel Scherer 1cd6e4451f Map.filter_map and Set.filter_map 2020-03-31 15:01:41 +02:00
Jacques Garrigue e10e2bfa99
add optional argument principality examples (#9405) 2020-03-31 13:52:22 +02:00
Greta Yorsh 824ce35492
Replace caml_int_compare and caml_float_compare with primitives (#2324) 2020-03-26 10:58:10 +01:00
David Allsopp e4f3aa8c81 Don't assume . in AWKPATH
Ensure all script invocations explicitly refer to a directory.
2020-03-20 09:38:33 +00:00
David Allsopp bc867cebf8 Use $AWK not awk
Ensures gawk is used if available.
2020-03-20 09:36:07 +00:00
Jérémie Dimino c7de942730
Fix #9344 (#9368)
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
2020-03-17 11:38:45 +00:00
Stephen Dolan 6246d5ce03
Merge pull request #9367 from stedolan/unify-backtraces
Make bytecode and native-code backtraces agree
2020-03-17 10:45:34 +00:00
Stephen Dolan 07d0192b22 Generate the same backtraces for method send in bytecode and native 2020-03-16 18:15:09 +00:00
Stephen Dolan cc7b687a02 Generate the same locations for raises in bytecode and native code 2020-03-16 18:15:09 +00:00
Jérémie Dimino e54876a869
Add a new toplevel directive #use_output "<command>"
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Co-authored-by: David Allsopp <david.allsopp@metastack.com>
2020-03-16 17:48:41 +00:00
Gabriel Scherer 0fff7a43c5
Merge pull request #9196 from gasche/clarify-disambiguation-3
disambiguation: improve the interface of `NameChoice.disambiguate`
2020-03-09 13:39:32 +01:00
Gabriel Scherer bf6c8d4b95 disambiguation: improve the API of NameChoice.disambiguate 2020-03-07 14:35:05 +01:00
Thomas Refis c323d11144
Merge pull request #8934 from trefis/usage
Stop relying on location to track usage
2020-03-06 16:49:44 +01:00
Florian Angeletti b82d5194c2
Merge pull request #9343 from lpw25/fix-short-paths-environments
Re-enable `-short-paths` for some error messages
2020-03-06 09:38:40 +01:00
Thomas Refis dacf8b5a0b typecore: wrap_unpacks => type_unpacks
This allows us to give the same uid to the module bound in the guard,
and the one bound in the rhs.
2020-03-05 13:35:14 +01:00
Thomas Refis 7e370000d3 update testsuite 2020-03-05 13:35:14 +01:00
Leo White 971ffafffb Apply short-paths to an additional case 2020-03-05 09:44:18 +00:00
Leo White 1188af3614 Fix some bugs in short-paths 2020-03-03 18:04:47 +00:00
Leo White 9de0113e94 Add test for short-paths in error messages 2020-03-03 18:01:13 +00:00
David Allsopp cf2db2b625 tests/tool-ocamldep-modalias is not parallel 2020-02-27 13:34:39 +00:00
David Allsopp 48e7150cc8 Testsuite is not parallel 2020-02-26 10:08:56 +00:00
David Allsopp 67c011b883
Revert "AppVeyor speed-ups" 2020-04-20 09:55:54 +01:00
David Allsopp c97b73c056
Merge pull request #9454 from dra27/faster-appveyor
AppVeyor speed-ups
2020-04-20 09:53:51 +01:00
David Allsopp 9fdd31f11b tests/tool-ocamldep-modalias is not parallel 2020-02-27 13:34:39 +00:00
David Allsopp 2ddcdf10a8 Testsuite is not parallel 2020-02-26 10:08:56 +00:00
Stephen Dolan de9e630852 Assert that Cassign is only used on Clet_mut-bound variables 2020-02-25 15:23:38 +00:00
Stephen Dolan 1336ce0c0d Use typing information from Clambda for mutable Cmm variables 2020-02-25 15:03:14 +00:00
Florian Angeletti bb15443a23 Revert "Make asmgen tests run"
This reverts commit e168edc67d.
2020-02-24 11:20:14 +01:00
Gabriel Scherer 9d8897db14
Merge pull request #9318 from trefis/empty_in_or_pattern
Fix exhaustivity checking in presence of empty types
2020-02-21 13:12:34 +01:00
Guillaume Bury 0d362f6abf Fix arith.cmm test
An error was triggered on the floating point computations because of
rounding errors between the read from the D array, and the C-side fp
computation which used 80-bit precision.
2020-02-20 15:37:39 +01:00
Guillaume Bury e168edc67d Make asmgen tests run
Relative paths are needed in ocamltest (rather than plain executable
file names), because else 'execvp' searches for the executable in the
PATH instead of the current directory.
2020-02-20 15:37:30 +01:00
Stefan Muenzel 6b94a5500d Add a test showing that the exhaustiveness check doesn't work with the empty variant 2020-02-19 13:30:16 +01:00
Florian Angeletti edabf2008c Merge pull request #9292 from lpw25/fix-best-fit-32-bit
Fix bug in best-fit on 32-bit

(cherry picked from commit 9e52341ece4e8c73087d622d2900cf3a97c6fe7b)
2020-02-11 10:45:36 +01:00
Nicolás Ojeda Bär 87296ee8e0
Dynlink: preserve module initializers backtrace (#9183)
* dynlink: preserve backtrace of module initializers
* Stabilize debug event sort
* Update test reference file
2020-02-06 07:21:23 +01:00
Pieter Goetschalckx 99224a96b7
Quoted extensions in comments, ocamllex and ocamlyacc (#9166)
* Support quoted extensions in comments
* Support quoted extensions in ocamllex
* Support quoted extensions in ocamlyacc
* Fix copying of comments in ocamlyacc
2020-02-03 10:55:28 +01:00
Gabriel Scherer e1addb7962
Merge pull request #9269 from Octachron/fix_annot
#9218: wrong file name error with -annot and inline records
2020-01-30 08:41:20 +01:00
Gabriel Scherer 13ab6b4a64
Merge pull request #2188 from rlepigre/recursive-yet-unboxed
Recursive yet unboxed
2020-01-29 10:16:33 +01:00
Florian Angeletti 9f696f0a8e 9218, avoid module/type path collitsion
In presence of -annot, the type printer can be requested to print the
inner path of inline records (i.e "t.A"). Before this commit, the
printing of these paths could trigger a lookup to a module with a
invalid name "t".
If this lookup fails this is fine.
However, if there is a cmi file in the environment sharing the name "t",
the lookup can partially succeed (since cmi are not required to start
with a capital letter) until we compare the module name stored in the
cmi with the requested module name.
Obviously, the valid module name "T" of the cmi cannot match the invalid
module name "t" that was requested, and the cmi reader raises a wrong
module file name error.

This commit avoids this whole process by detecting in the type printer
when we are printing an inlined record type constructor.
2020-01-28 16:30:56 +01:00
Jacques-Henri Jourdan ca5f81ccd0 Fix callstack test by forcing flambda not to optimize. 2020-01-28 14:47:20 +00:00
Jacques-Henri Jourdan 35104694b5 Fix test comballoc.ml 2020-01-28 14:47:20 +00:00
Gabriel Scherer e940f925ad typedecl_separability: handle GADT equations in a more predictable order
The separability signature of a type declaration is not inferred in
a principal way, it depends on the order in which GADT equations are
processed. In non-principal cases, we may have two parameters that are
related by an equality, with one of them being given mode Ind and the
other Sep. Either choice of which to make Sep is sound, but (Ind, Ind)
would be unsound.

We change the implementation to ensure that equations are processed in
an order such that the lefmost parameters are the most constained: if
equations imply that ('a = 'b), with the parameter 'a coming before 'b
in the type declaration, and they must be separable, then 'a gets the
mode Sep and 'b gets the mode Ind. This corresponds intuitively to
remembering that 'b is equal to a previous parameter, instead of
remembering than 'a is equal to a not-seen-yet parameter.
2020-01-28 13:56:23 +01:00
Gabriel Scherer c62c9d19f9 separability: add some interesting examples to the testsuite 2020-01-28 12:09:33 +01:00
Rodolphe Lepigre 15a6ff229d typedecl: use the new Separability implementation, remove old code
Because this changes the separability of standard library types, and
those separabilities are stored in the .cmi files, this commit changes
the .cmi files in the standard libraries in way that appear to require
a bootstrap (it looks like some part of the stdlib is built with
boot/ocamlc and others with ocamlc, and the two should produce/expect
the same .cmi exactly). The bootstrap will come as a separate commit.
2020-01-28 12:09:33 +01:00
Rodolphe Lepigre 20b62c8386 Cleaned up [@@unbox] validity check. 2020-01-28 11:39:52 +01:00
Stephen Dolan f874b3ee01 Memprof: report different callstacks for different combined allocations 2020-01-25 22:55:56 +01:00
Stephen Dolan 07bf49db5b Statmemprof support for native allocations (incl. Comballoc) 2020-01-25 22:55:56 +01:00
Gabriel Scherer d408e58ea1
Merge pull request #9261 from lthls/rec_check_ignore_fix
Fix soundness bug in Rec_check with anonymous let module
2020-01-24 22:06:37 +01:00
Gabriel Scherer a6825861ee
Merge pull request #9247 from jhjourdan/memprof-byte-loc
Memprof: get precise callstacks when memory is allocated directly in the bytecode interpreter
2020-01-24 22:06:00 +01:00
Vincent Laviron 31a14e3082 Fix the regression test 2020-01-24 14:50:48 +01:00
Vincent Laviron 643fe20ab0 Add regression test 2020-01-24 14:29:56 +01:00
Florian Angeletti dc56d71b53 types: allow class type paths in #t 2020-01-20 17:21:02 +01:00
Leo White c272447b1e Relax the handling of explicit polymorphic types 2020-01-20 13:48:16 +00:00
Jeremy Yallop 73a37d45f8 Add Seq.unfold. 2020-01-15 15:38:46 +00:00
Jacques-Henri Jourdan c4d7bcd352 Memprof: get precise callstacks when memory is allocated directly in the bytecode interpreter.
This includes two changes: first, in bytegen.ml, we add a pseudo-event after every allocation or closure instruction. Second, in the interpreter, we save the current PC in the interpreter stack in [Setup_for_gc].
2020-01-15 11:59:51 +01:00
Jacques-Henri Jourdan e1a22e80fb Memprof API: cannot be start if already running, cannot be stopped if not already running. 2020-01-14 10:42:16 +01:00
Jeremy Yallop 38eb6d5f64
Add Array.for_all2 and Array.exists2 (#9235)
* Partially revert "Removed for_all2, exists2 and find again."

This partially reverts commit 83dcf62ebf.

(Restore for_all2 and exists2.)

* Partially revert "Fixed typos and changed exists2 and for_all2."

This partially reverts commit 7a082785be.

* Array.(for_all2,exists2): simplify documentation; add @since annotations

* Changes: remove trailing whitespace
2020-01-13 13:52:39 +00:00
Jacques-Henri Jourdan 0c8416478c Drop support for tags in memprof.
They are somewhat difficult to handle for native allocations, and it is not clear how useful they are. Moreover, they are easy to add back since [Gc.Memprof.allocation] is a private record.
2020-01-11 13:19:10 +01:00
Gabriel Scherer 8a79f6ce59
Merge pull request #9021 from Octachron/longident_parser
Expose parsers for Longident.t
2020-01-10 11:23:09 +01:00
Florian Angeletti 4fdba2f638 Merge pull request #9185 from hhugo/fix-unused-open
fix spurious 'unused open' warning with classes and polymorphic variants

(cherry picked from commit d2c4e791fad6340c74abf741af3e79eb1f9c20d7)
2020-01-10 09:49:02 +01:00
Gabriel Scherer 8d8e991ced
Merge pull request #9208 from gasche/dno-locations
-dno-locations: hide source locations (and debug events) from intermediate-representation dumps
2020-01-10 06:56:48 +01:00
Florian Angeletti 40e40a9c20 compilerlibs: expose parsers for 'Longident.t's 2020-01-09 16:45:39 +01:00
Gabriel Scherer 50da1ce8c3 Merge pull request #9212 from kit-ty-kate/fix-dynlink
Fix access to C symbols when using Dynlink

(cherry picked from commit c67990cedea7932b5b1a877c1479c9b7b9f910da)
2020-01-09 15:28:38 +01:00
Gabriel Scherer 8938886721 -dno-locations: hide source locations (and debug events) from IR dumps
This PR was tested with also the -dsel, -dlinear output (also fixed to
not-print locations), but the output is architecture-dependent so this
part of the test was removed.
2020-01-09 15:25:16 +01:00
Jacques-Henri Jourdan 52661f14a4 Make ocamlc preserve events after primitives even if they are at tail position. 2020-01-09 00:16:42 +01:00
Gabriel Scherer 73bed21afe
Merge pull request #9225 from stedolan/bytecode-debug-info-dropped
Do not drop bytecode debug info after C calls
2020-01-07 22:05:09 +01:00
Stephen Dolan 2d21433573 Do not drop bytecode debug info after C calls 2020-01-07 10:32:41 +00:00
Jacques-Henri Jourdan d5d972d377 Fix test c-api/alloc_async_stubs.c.
We must wait for two major cycles to finish in order to make sure that finalizers have indeed be examined.
2020-01-06 14:16:12 +01:00
Jacques-Henri Jourdan 7dbbfce890 New ephemeron-free API for Memprof.
The user can register several callbacks, which are called for various
events during the block's lifetime. We need to maintain a data
structure for tracked blocks in the runtime. When using threads,
callbacks can be called concurrently in a reentrant way, so the
functions manipulating this data structure need to be reentrant.
2019-12-21 10:21:48 +01:00
Stephen Dolan 291cbaf1d1 Make tuple matching optimisation apply to Lswitch and Lstringswitch. 2019-12-19 14:29:34 +00:00
Fourchaux 1f9474c63c Fixing typos (#9162) 2019-12-04 19:38:02 +00:00
Jacques Garrigue a33f80bf00
fix typo in name + improve style in type_pat (#9161) 2019-12-04 15:06:17 +01:00
Gabriel Scherer f572295def
Merge pull request #463 from gasche/robust-ocamlobjinfo
objinfo: tell when the object file comes from a different OCaml version
2019-12-03 10:36:13 +01:00
Gabriel Scherer 9d81d6a10e new Misc.Magic_number module for magic number handling
This module was originally inspired by js_of_ocaml Misc.MagicNumber module
https://github.com/ocsigen/js_of_ocaml/blob/151b811/compiler/util.cppo.ml#L277-L347

It provides parsing and validation function for magic numbers, that
can tell the difference between "not a valid magic number" and "a
valid magic number, but with another version", and print user-friendly
user messages about it.

It does not contain any knowledge for where to find the magic number
in an OCaml file (this depends on the file format); the parsing
function should be called with an input channel already at the right
position for whichever format is expect.
2019-12-03 00:08:29 +01:00
Jacques Garrigue 27ef14dab9
Fix exhaustivity of GADTs coming from incomplete unification (#9154) 2019-12-02 20:49:51 +01:00
Florian Angeletti b768c0be59 Highlighting in the manual
* Replace caml-sl with the standard listings package
and ulem package
* update caml_tex to output nicer latex code
* simplify escaping in caml_tex
2019-11-28 11:45:08 +01:00
Gabriel Scherer 05f15cf215
Merge pull request #8820 from Drup/stringquot
Quoted extensions
2019-11-25 21:26:53 +01:00
David Allsopp 504d95c275 Fix formatting of closing brace in records 2019-11-21 12:06:53 +00:00
David Allsopp 2c82bfb35b
Merge pull request #9121 from dra27/fix-force-safe-string
Fix error in patch to configure.ac from #1859, with follow-on corrections
2019-11-17 08:44:38 +00:00
Konstantin Romanov a9b0ca44d2 Add set_position and set_filename to Lexing. 2019-11-16 22:14:16 +00:00
David Allsopp 2801fdf011 Fix cloexec test for force-safe-string 2019-11-14 11:18:43 +00:00
Gabriel Scherer 757a64464f ocamldoc: better support of multiline code blocks in the manpage backend
Before, `man Map` would show:

```
For instance: module IntPairs = struct type t = int * int let compare (x0,y0) (x1,y1) = match Stdlib.compare x0 x1 with 0 -> Stdlib.compare y0 y1 |
c -> c end module PairsMap = Map.Make(IntPairs) let m = PairsMap.(empty |> add (0,1) hello |> add (1,0) world )
```

Now it shows:

```
For instance:
     module IntPairs =
       struct
         type t = int * int
         let compare (x0,y0) (x1,y1) =
           match Stdlib.compare x0 x1 with
               0 -> Stdlib.compare y0 y1
             | c -> c
       end

     module PairsMap = Map.Make(IntPairs)

     let m = PairsMap.(empty |> add (0,1) "hello" |> add (1,0) "world")
```

(in both cases the code is in bold)
2019-11-14 11:31:05 +01:00
Drup 4092d8fc49 Fix locations for quoted extensions ids. 2019-11-13 16:08:41 +01:00
Drup 9c8b63f4ce Annotated Asttypes.constant's string with content location. 2019-11-13 16:08:40 +01:00
Drup abc53d1a6e Annotate constant literals with the location of their content. 2019-11-13 16:08:40 +01:00
Drup ddbfa18ab9 Test quoted extensions. 2019-11-13 14:54:28 +01:00