Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006359OCamlOCaml backend (code generation)public2014-04-01 19:562014-04-02 15:24
Reporterchambart 
Assigned Tomaranget 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.02.0+dev 
Summary0006359: not merged equal pattern matching branches
DescriptionIn the following example (extracted from ocamlnet), the fields extractions of n and g for cases `A and `D are not merged.

match `C with
| `A(n,g)
| `D(n,g) -> n + g
| _ -> 0

In the resulting lambda
# ocamlc -c -drawlambda example.ml
(setglobal Example!
  (seq
    (let (match/1012 67a)
      (catch
        (catch
          (if (isint match/1012) (exit 2)
            (let (variant/1019 (field 0 match/1012))
              (if (!= variant/1019 65)
                (if (!= variant/1019 68) (exit 2)
                  (let
                    (match/1017 (field 1 match/1012)
                     g/1016 (field 1 match/1017)
                     n/1015 (field 0 match/1017))
                    (exit 1 n/1015 g/1016)))
                (let
                  (match/1017 (field 1 match/1012)
                   g/1016 (field 1 match/1017)
                   n/1015 (field 0 match/1017))
                  (exit 1 n/1015 g/1016)))))
         with (2) 0)
       with (1 n/1008 g/1009) (+ n/1008 g/1009)))
    (makeblock 0)))

This is not strictly speaking a bug since it does not impact anything,
but I would like to assume that identifiers can't be bound multiple times
(in my backend patches) and this is the only case I know (in the opam
repository) where this don't hold.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0011169)
garrigue (manager)
2014-04-02 04:28

Multiple binding of the same identifier is a bug: there are already parts of the backend where this invariant is assumed, and I have generated wrong code by just breaking it.
Whether to merge the branches or not is another question.
(0011171)
maranget (manager)
2014-04-02 11:20

This is indeed a bug, and it is related to sharing!
(The match compiler re-shares actions which are alpha-equivalent
but this sharing is lost in the case for instance of variants.

--Luc
(0011173)
maranget (manager)
2014-04-02 15:24

Bug fixed in trunk. Thanks to all.

--Luc

- Issue History
Date Modified Username Field Change
2014-04-01 19:56 chambart New Issue
2014-04-02 04:28 garrigue Note Added: 0011169
2014-04-02 11:20 maranget Note Added: 0011171
2014-04-02 11:22 maranget Assigned To => maranget
2014-04-02 11:22 maranget Status new => confirmed
2014-04-02 15:23 maranget Status confirmed => resolved
2014-04-02 15:23 maranget Resolution open => fixed
2014-04-02 15:23 maranget Fixed in Version => 4.02.0+dev
2014-04-02 15:24 maranget Note Added: 0011173


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker