Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000319OCamlOCaml generalpublic2001-03-21 14:352001-03-26 15:18
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000319: O'Caml 3.01: Fatal error: Bytegen.comp_expr and Selection.size_expr
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]
*)

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000540)
administrator (administrator)
2001-03-21 18:54

>
> (* 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 ()
  

(0000541)
administrator (administrator)
2001-03-26 15:18

Fixed 2001-03-21 by Luc

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker