Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006651OCamltypingpublic2014-11-09 16:122017-09-24 17:32
Reporterlpw25 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.03.0+dev / +beta1 
Summary0006651: Failing component lookup
DescriptionThe following code works:

    module type S = sig
      module type T
      module X : T
    end

    module M = struct
      module type T = sig type t end
      module X = struct type t = int end
    end

    module F (X : S) = X.X

    type t = F(M).t

However, if we change the order of the definitions of `F` and `M`:

    module type S = sig
      module type T
      module X : T
    end

    module F (X : S) = X.X

    module M = struct
      module type T = sig type t end
      module X = struct type t = int end
    end

    type t = F(M).t

then it fails:

    $ ocamlc -c test.ml
    File "test.ml", line 13, characters 13-19:
    Error: Unbound type constructor F(M).t

This is because `components_of_module_maker` uses the environment from the definition of `F` to perform `scrape_alias`, so it does not see the definition of `M` if it is defined after `F`.
TagsNo tags attached.
Attached Filesdiff file icon env.diff [^] (5,220 bytes) 2014-11-12 12:45 [Show Content]

- Relationships
related to 0000051closed Subtle functor application bug 
related to 0007192resolved Strange type system bug 

-  Notes
(0012502)
garrigue (manager)
2014-11-10 08:16

Just to clarify: the problem is not new; you get exactly the same error message with 3.08 for instance.
Will look into it.
(0012504)
garrigue (manager)
2014-11-10 08:53

The env.diff patch solves this problem by replacing the environment inherited from the functor by the current one.
The test suite goes through, so this does not seem too bad.
However, this means that we would no longer be using the fcomp_env field, and this field comes with the comment "Environment in which the result signature makes sense". This seems to imply that without it it does not make sense, so maybe we need a specialist to check this.
(0012522)
garrigue (manager)
2014-11-12 12:47

Updated env.diff, as it was breaking PR#51.
The trick seems to do all the substitutions eagerly...
(0012523)
garrigue (manager)
2014-11-12 13:00

Fixed in trunk at revision 15576.
However, I'm not 100% sure so need to check more programs.

- Issue History
Date Modified Username Field Change
2014-11-09 16:12 lpw25 New Issue
2014-11-10 08:16 garrigue Note Added: 0012502
2014-11-10 08:46 garrigue File Added: env.diff
2014-11-10 08:53 garrigue Note Added: 0012504
2014-11-10 10:10 garrigue Assigned To => garrigue
2014-11-10 10:10 garrigue Status new => assigned
2014-11-12 12:45 garrigue Relationship added related to 0000051
2014-11-12 12:45 garrigue File Deleted: env.diff
2014-11-12 12:45 garrigue File Added: env.diff
2014-11-12 12:47 garrigue Note Added: 0012522
2014-11-12 13:00 garrigue Note Added: 0012523
2014-11-12 13:00 garrigue Status assigned => resolved
2014-11-12 13:00 garrigue Fixed in Version => 4.03.0+dev / +beta1
2014-11-12 13:00 garrigue Resolution open => fixed
2016-04-25 14:47 doligez Relationship added related to 0007192
2017-02-23 16:45 doligez Category OCaml typing => typing
2017-09-24 17:32 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker