Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007284OCamltypingpublic2016-07-05 14:342017-09-24 17:33
Reporterlpw25 
Assigned Togarrigue 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version4.03.0 
Target VersionFixed in Version4.04.0 +dev / +beta1 / +beta2 
Summary0007284: Bug in mcomp_fields leads to segfault
DescriptionI think that this condition in `mcomp_fields`:

  if miss1 <> [] && (object_row ty1).desc = Tnil
  || miss2 <> [] && (object_row ty2).desc = Tnil then raise (Unify []);

is supposed to be:

  if miss1 <> [] && (object_row ty2).desc = Tnil
  || miss2 <> [] && (object_row ty1).desc = Tnil then raise (Unify []);

As it stands the check treats some compatible types as incompatible. For example, the following code gives a segmentation fault:

  module type S = sig

    type o1 = < bar : int; foo : int >
    type o2 = private < foo : int; .. >

    type v1 = T of o1
    type v2 = T of o2

  end

  module M = struct

    type o1 = < bar : int; foo : int >
    type o2 = o1

    type v1 = T of o1
    type v2 = v1 = T of o2

  end

  module F(X : S) = struct

    type 'a wit =
    | V1 : string -> X.v1 wit
    | V2 : int -> X.v2 wit

    let f : X.v1 wit -> unit = function V1 s -> print_endline s

  end

  module N = F(M)

  let () = N.f (N.V2 0)
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0016039)
garrigue (manager)
2016-07-06 03:50

Fixed in trunk by commit cae15ea.

The code for the object case was completely broken.
Actually, the correct condition is even a bit more complex, but this was overlooked.
The variant case was checked more carefully.

- Issue History
Date Modified Username Field Change
2016-07-05 14:34 lpw25 New Issue
2016-07-06 03:50 garrigue Note Added: 0016039
2016-07-06 03:50 garrigue Status new => resolved
2016-07-06 03:50 garrigue Fixed in Version => 4.04.0 +dev / +beta1 / +beta2
2016-07-06 03:50 garrigue Resolution open => fixed
2016-07-06 03:50 garrigue Assigned To => garrigue
2017-02-23 16:45 doligez Category OCaml typing => typing
2017-09-24 17:33 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker