Comments (11)
@Octachron and myself have now fixed this issue -- the uncaught exception. The fix will be included in next release of 4.14, and in OCaml 5.2 and later releases. We found some independent issues with the same or related test cases, that have yet to be fixed.
from ocaml.
from ocaml.
Nice find!
This is related to the handling of the (equi)-recursive types built by this incorrect program. The failure is reproducible starting with OCaml 4.13, but 4.12 and 4.11 (older versions don't have Seq) fail with a proper error:
File "test.ml", lines 4-5, characters 2-22:
4 | ..let T x = xt in
5 | Seq.cons Seq.empty x
Error: This expression has type
('a Seq.t as 'a) Seq.t Seq.t = unit -> 'a Seq.t Seq.node
but an expression was expected of type 'b
Type 'c is not compatible with type 'a = unit -> 'c Seq.node
The type variable 'c occurs inside 'a
The program also gets accepted when -rectypes
is used, including on recent versions.
val to_seq : ('a Seq.t as 'a) Seq.t t -> 'a Seq.t Seq.t
from ocaml.
Testing indicates that this failure was introduced by #10170 .
from ocaml.
Minimal repro case (does not rely on an external module):
type 'a t = T of 'a
module Seq : sig
type 'a t = unit -> 'a node
and 'a node
val empty : 'a t
val cons : 'a -> 'a t -> 'a t
end = struct
type 'a t = unit -> 'a node
and 'a node = unit
let empty () = ()
let cons x xs () = ()
end
let to_seq (xt : 'a t) : 'a Seq.t =
let T x = xt in
Seq.cons Seq.empty x
from ocaml.
I proposed a one-line fix in #10170 (comment) . But in fact, it looks like this error cannot be reproduced in trunk and in the 5.2 release branch, thanks to another change in 52 ( #12691 ). So in a sense it is "already fixed", even though we may still want to apply the proper one-line fix.
from ocaml.
I think I might prefer to backport the expand_gen_abbrev
cleanup from #12691 to 4.14 (to have the same behavior on 4.14.2+ and 5.2+).
from ocaml.
My impression is that the one-line change makes the code more consistent. I don't understand if the expand_gen_abbrev
change makes all of that code inconsistent again (maybe there is no need to use the _safe
variant anymore in most cases?), but I would be inclined to make all callsites look the same independently of that change -- which we could also backtrack to 4.14, even if it is noticeably more invasive.
from ocaml.
I proposed my one-liner with the repro case as a PR in #12974.
from ocaml.
Further testing indicates that the rectype bug is quite old:
(* core.mli *)
type 'a pre = Nil | Cons of 'a * 'a pre
type 'a t = unit -> 'a pre
val cons: 'a -> 'a t -> 'a t
val empty: 'a t
(* main.ml *)
let cons_empty (x : 'a) : 'a Core.t = Core.(cons empty x)
has been broken since 4.01 .
from ocaml.
Thanks for the report!
from ocaml.
Related Issues (20)
- Improve type error explanation for partially applied functor HOT 3
- TMC on 5.2 generates unexpected lambda for Melange HOT 8
- Missed ignored partial application due to ignored named binding HOT 6
- Atomic mutable fields for objects HOT 1
- Runtime events does not cleanup pid.events file on SIGSTOP HOT 3
- Clarify @noalloc documentation HOT 1
- [5.2] build error: dllunixbyt.so_The boot compiler cannot load DLLs: No such file or directory HOT 5
- Go to definition in VS Code HOT 4
- undefined symbol: caml_zstd_initialize when building ppx using OCaml built with --without-zstd HOT 2
- Wrong interface mli generation in for loops HOT 1
- Improve error message for optional arguments mismatches
- Error installing 5.1.1: zstd/lib/libzstd.so: undefined reference to `pthread_create@GLIBC_2.34' HOT 3
- Stamps of identifiers are not unique HOT 5
- Test `statmemprof/exception_comballoc` fails under TSan (possibly TSan-internal bug) HOT 25
- ThreadSanitizer CI failures on a PR are not shown in the Github UI HOT 4
- [TSan] ocamlrun should never be linked with `-fsanitize=thread`
- Parallel Dynlink usage under Cygwin+MinGW is unsafe
- Misplaced attributes for deprecation markers HOT 7
- Officially add a Directives module to eschew toplevel directives syntax
- [TSan] Random failure of `tests/parallel/domain_dls.ml` HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocaml.