Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007414OCamltypingpublic2016-11-16 12:002016-12-10 02:55
Reporterlpw25 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.04.0 
Target VersionFixed in Version4.05.0 +dev/beta1/beta2/beta3/rc1 
Summary0007414: Soundness bug with non-generalized type variable and functors
DescriptionThe interplay between non-generalized type variables and functors seems ill defined and unsound. Using first-class modules we can get a segfault:

  module type T = sig
    type t
    val x : t
    val show : t -> string
  end

  module Int = struct
    type t = int
    let x = 0
    let show x = string_of_int x
  end

  module String = struct
    type t = string
    let x = "Hello"
    let show x = x
  end

  let switch = ref true

  module Choose () = struct
    module Choice =
      (val if !switch then (module Int : T)
           else (module String : T))
    let r = ref (ref [])
  end

  module type S = sig
    module Choice : T
    val r : Choice.t list ref ref
  end

  module Force (X : functor () -> S) = struct end

  module M = Choose ()

  let () = switch := false

  module N = Choose ()

  let () = N.r := !M.r

  module Ignore = Force(Choose)

  module M' = (M : S)

  let () = (!M'.r) := [M'.Choice.x]

  module N' = (N : S)

  let () = List.iter (fun x -> print_string (N'.Choice.show x)) !(!N'.r)
TagsNo tags attached.
Attached Files

- Relationships
related to 0006752resolvedgarrigue Extensible variant types and scope escaping 

-  Notes
(0016594)
garrigue (manager)
2016-11-19 01:31

I've created a pull-request https://github.com/ocaml/ocaml/pull/929 [^] with a fix.
Note that the current fix is not very efficient, so I will revise it before merging,
to use an iterator rather than Subst.modtype.
(0016598)
garrigue (manager)
2016-11-21 14:22

Merged the pull request in commit 2bd22967.
Now handled by a visit of the signature rather than by Subst.

- Issue History
Date Modified Username Field Change
2016-11-16 12:00 lpw25 New Issue
2016-11-16 13:30 shinwell Assigned To => garrigue
2016-11-16 13:30 shinwell Status new => assigned
2016-11-19 01:31 garrigue Note Added: 0016594
2016-11-19 01:31 garrigue Status assigned => confirmed
2016-11-21 14:22 garrigue Note Added: 0016598
2016-11-21 14:22 garrigue Status confirmed => resolved
2016-11-21 14:22 garrigue Fixed in Version => 4.05.0 +dev/beta1/beta2/beta3/rc1
2016-11-21 14:22 garrigue Resolution open => fixed
2016-12-10 02:55 garrigue Relationship added related to 0006752
2017-02-23 16:45 doligez Category OCaml typing => typing


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker