Skip to content
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

O'Caml 3.01: Fatal error: Bytegen.comp_expr and Selection.size_expr #2721

Closed
vicuna opened this issue Mar 21, 2001 · 2 comments
Closed

O'Caml 3.01: Fatal error: Bytegen.comp_expr and Selection.size_expr #2721

vicuna opened this issue Mar 21, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Mar 21, 2001

Original bug ID: 319
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

(* This is a minimal example that makes no sense, but illustrates a bug
in OR patterns with binding in O'Caml 3.01, that appeared in a much
larger real world application.

ohl@thopad:~/ml/omega/src > ocamlc -c ocaml-bug.ml
p/62

Fatal error: Bytegen.comp_expr: var p_62
Uncaught exception: Misc.Fatal_error

ohl@thopad:~/ml/omega/src > ocamlopt -c ocaml-bug.ml

Fatal error: Selection.size_expr: unbound var p_62
Uncaught exception: Misc.Fatal_error

ohl@thopad:~/ml/omega/src > ocamlc -v
The Objective Caml compiler, version 3.01
Standard library directory: /usr/local/lib/ocaml
*)

type ab = A of int | B of int
type cd = C | D

let f = function
| (A (p) | B (p)), C -> A (p)
| (A (p) | B (p)), D -> B (p)

(*
Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de
http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]
*)

@vicuna
Copy link
Author

vicuna commented Mar 21, 2001

Comment author: administrator

(* This is a minimal example that makes no sense, but illustrates a bug
in OR patterns with binding in O'Caml 3.01, that appeared in a much
larger real world application.

...

*)

type ab = A of int | B of int
type cd = C | D

let f = function
| (A (p) | B (p)), C -> A (p)
| (A (p) | B (p)), D -> B (p)

(*
Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de
http://heplix.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]
*)

The bug is corrected in the development sources.

Thank you for reporting the bug.

--Luc Maranget

Here is a diff (there are other changes, the important one is
the second change ``*** 753,759 ***'').

*** matching.ml Sat Mar 3 01:14:03 2001
--- /home/beaune/moscova3/maranget/Conti/csl/bytecomp/matching.ml Wed Mar 21 17:52:51 2001


*** 621,627 ****
let env = mk_alpha_env arg aliases vars in
(alpha_pat env p::patl,mk_action (List.map snd env))::rem

  • let equiv_pat p q = le_pat p q && le_pat q p

    let rec get_equiv p l = match l with
    --- 621,626 ----


*** 753,759 ****
| (q::qs,act_q) as cl::rem ->
if is_or q then begin
if compat p q then
! if equiv_pat p q then (* attempt insert )
let _, not_e = get_equiv q rem in
if
or_ok p ps not_e && (
check append condition for head of O )
--- 752,762 ----
| (q::qs,act_q) as cl::rem ->
if is_or q then begin
if compat p q then
! if
! IdentSet.is_empty (extract_vars IdentSet.empty p) &&
! IdentSet.is_empty (extract_vars IdentSet.empty q) &&
! equiv_pat p q
! then (
attempt insert, for equivalent orpats with no variables )
let _, not_e = get_equiv q rem in
if
or_ok p ps not_e && (
check append condition for head of O *)


*** 2065,2072 ****
{ cases = List.map (fun (pat, act) -> ([pat], act)) pat_act_list;
args = [arg, Strict] ;
default = raise_num,[[[omega]],raise_num]} in
! let (lambda, total) = compile_match repr partial (start_ctx 1) pm in
! check_total total lambda raise_num handler_fun
| Total ->
let pm =
{ cases = List.map (fun (pat, act) -> ([pat], act)) pat_act_list;
--- 2068,2079 ----
{ cases = List.map (fun (pat, act) -> ([pat], act)) pat_act_list;
args = [arg, Strict] ;
default = raise_num,[[[omega]],raise_num]} in
! begin try
! let (lambda, total) = compile_match repr partial (start_ctx 1) pm in
! check_total total lambda raise_num handler_fun
! with
! | Unused -> handler_fun()
! end
| Total ->
let pm =
{ cases = List.map (fun (pat, act) -> ([pat], act)) pat_act_list;


*** 2157,2165 ****
args = List.map (fun id -> (Lvar id, Strict)) paraml ;
default = raise_num,[omegas,raise_num]
} in
! let (lambda, total) = compile_match None partial
! (start_ctx (List.length paraml)) pm in
! check_total total lambda raise_num (partial_function loc)

let for_multiple_match loc paraml pat_act_list partial =
let repr = None in
--- 2164,2175 ----
args = List.map (fun id -> (Lvar id, Strict)) paraml ;
default = raise_num,[omegas,raise_num]
} in
! try
! let (lambda, total) = compile_match None partial
! (start_ctx (List.length paraml)) pm in
! check_total total lambda raise_num (partial_function loc)
! with
! | Unused -> partial_function loc ()

let for_multiple_match loc paraml pat_act_list partial =
let repr = None in


*** 2177,2182 ****
--- 2187,2193 ----
default = -1,[] } in

try
  • try

    let next,nexts = separe None pm1 in


*** 2204,2209 ****

with Cannot_flatten ->
  let (lambda, total) = compile_match None partial (start_ctx 1) pm1 in

! check_total total lambda raise_num (partial_function loc)
!

--- 2215,2227 ----

with Cannot_flatten ->
  let (lambda, total) = compile_match None partial (start_ctx 1) pm1 in

! begin match partial with
! | Partial ->
! check_total total lambda raise_num (partial_function loc)
! | Total ->
! assert (jumps_is_empty total) ;
! lambda
! end
! with Unused ->
! partial_function loc ()

@vicuna
Copy link
Author

vicuna commented Mar 26, 2001

Comment author: administrator

Fixed 2001-03-21 by Luc

@vicuna vicuna closed this as completed Mar 26, 2001
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant