New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assertion failure exclusively with 4.06.1+rc1 #7713
Comments
Comment author: @trefis And indeed:
exception A of intexception B of int * int;; let f g = try g () with A (1 | 2) -> 1 | B (1, 2) -> 2;;val f : (unit -> int) -> int = |
Comment author: @trefis Interesting, it doesn't fail with the toplevel, but fails with ocamlc. |
Comment author: @trefis The full backtrace is: Fatal error: exception File "typing/parmatch.ml", line 177, characters 12-18: Assertion failed Which makes more sense (that is: in a way, the issue comes from matching, not parmatch) |
Comment author: @nojb Is it possible to explain why the comment "(* By typing *)" in parmatch.ml is wrong? |
Comment author: @trefis nojebar: given the way we build "pattern matrices" we can't always assume that patterns in the same column of a matrix will be of the same type. Indeed we can easily produce counter examples using GADTs, as show cased here : https://github.com/ocaml/ocaml/blob/trunk/typing/parmatch.ml#L47 (introduced by #1550). |
Comment author: @trefis (N.B. the discrepancy I thought I observed between ocaml and ocamlc was obviously due to the fact that I forgot some parentheses when playing in the toplevel! Sorry for the noise.) |
Comment author: @maranget So do we cherry-pick or merge-in the whole PR 1550 ? |
Comment author: @gasche
I think you should have received the email titled "A note on pattern matching and 4.06.1", that I sent to caml-devel on December 19th, and explains the issue -- it also predicts that bugs such as this one may arise in the 4.06 branch. Luc, Thomas: re. merging vs. cherry-picking, I'm not sure which one we want, and also which one Damien will be comfortable merging in the release branch. I would like to understand whether we are confident that cherry-picking f5619dc would be sufficient to "silence" miscompilations without wrong-code generation or degradation to currently-correct warnings. Thomas, if you investigated the issue (I haven't yet), have you analyzed the usages of Parmatch in Matching, and are you confindent that this commit is "enough" for this class of issues? |
Comment author: @trefis Yes,f5619dc is the only commit of #1550 that affects Matching so it should be enough to cherry-pick it to fix that issue. Another question is: if we cherry-pick only that commit, in what kind of state do we leave Parmatch? Do we expose ourselves to other new bugs? Separately, I can confirm that a few weeks I managed to build janestreet's codebase with the whole GPR backported on 4.06. |
Comment author: @xavierleroy Fixed in 4.06.1 by backport, commit b2ac599 |
Original bug ID: 7713
Reporter: aha
Assigned to: @maranget
Status: resolved (set by @xavierleroy on 2018-06-09T08:43:31Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.06.1
Category: typing
Monitored by: @nojb @gasche
Bug description
The following code snippet triggers an assert failure with the first release candidate of OCaml 4.06.1. All previous OCaml versions and 4.07.0+trunk accept it:
exception A of int
exception B of (int * int)
let f g =
try
g ()
with
| A(1|2) -> 1
| B(1,2) -> 2
Fatal error: exception File "typing/parmatch.ml", line 177, characters 12-18: Assertion failed
The text was updated successfully, but these errors were encountered: