Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000051OCamlOCaml generalpublic2000-03-07 13:402014-11-12 12:45
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000051: Subtle functor application bug
Description

Hello!

I've been looking at Ocaml module system implementation recently and I
discovered a little subtle bug, which appears when you try to apply a
functor which is a component of a larger structure and whose type is a
"module type" defined in the same structure.....

Well, to be more explicit, here is an example of a functor F with the
caracteristics as described above, and the bug that is produced:

        Objective Caml version 2.04

# module X=struct
    module type SIG=sig type t=int val x:t end;;
    module F(Y:SIG) : SIG = struct type t=Y.t let x=Y.x end;;
  end;;
module X :
  sig
    module type SIG = sig type t = int val x : t end
    module F : functor(Y : SIG) -> SIG
  end
# module DUMMY=struct type t=int let x=2 end;;
module DUMMY : sig type t = int val x : int end
# (3 : X.F(DUMMY).t);;
Unbound type constructor X.F(DUMMY).t


Apparenly the type system does not know that there is a type
component "t" in the result of the application of X.F to DUMMY.
The same thing works perfectly well if SIG and F are defined at
toplevel:

 
        Objective Caml version 2.04

# module type SIG=sig type t=int val x:t end;;
module type SIG = sig type t = int val x : t end
# module F(Y:SIG) : SIG = struct type t=Y.t let x=Y.x end;;
module F : functor(Y : SIG) -> SIG
# module DUMMY=struct type t=int let x=2 end;;
module DUMMY : sig type t = int val x : int end
# (3 : F(DUMMY).t);;
- : F(DUMMY).t = 3



I haven't checked with the recent version of Ocaml, but I looked at
the CVS server and I think that the error will persist...


My guess is that the functor components evaluated for X.F in the
function "components_of_module", correspond to:
          fcomp_param = "Y"
          fcomp_arg = "X.SIG"
          fcomp_res = "X.SIG"
          fcomp_env = {... SIG -> sig...end ... }
And since there is no "X.SIG" in fcomp_env but only SIG, the function
"components_of_module_application" computes empty components structure
for X.F(DUMMY).


Best regards

Jacek Chrzaszcz

--
Laboratoire de Recherche en Informatique (LRI) - Equipe DEMONS
batiment 490, bureau 153, Universite Paris-Sud 91405 ORSAY (FRANCE)
tel:33.1.69.15.42.35 - fax:33.1.69.15.65.86 - http://www.lri.fr/~jacek [^]

TagsNo tags attached.
Attached Files

- Relationships
related to 0006651resolvedgarrigue Failing component lookup 

-  Notes
(0000318)
administrator (administrator)
2000-03-09 17:09

> I've been looking at Ocaml module system implementation recently and I
> discovered a little subtle bug, which appears when you try to apply a
> functor which is a component of a larger structure and whose type is a
> "module type" defined in the same structure.....
> # (3 : X.F(DUMMY).t);;
> Unbound type constructor X.F(DUMMY).t

Right. Thanks for spotting that problem.

> My guess is that the functor components evaluated for X.F in the
> function "components_of_module", correspond to:
> fcomp_param = "Y"
> fcomp_arg = "X.SIG"
> fcomp_res = "X.SIG"
> fcomp_env = {... SIG -> sig...end ... }
> And since there is no "X.SIG" in fcomp_env but only SIG, the function
> "components_of_module_application" computes empty components structure
> for X.F(DUMMY).

Your guess is correct. fcomp_res should be the result signature of
the functor before prefixing (so that it makes sense in fcomp_env),
and the prefixing substitution should be recorded in the
functor_components record for prefixing when components_of_module_app
computes the environment.

The working sources incorporate the fix.

All the best,

- Xavier Leroy

(0000319)
administrator (administrator)
2000-03-09 17:10

Fixed in 3.00

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2014-11-12 12:45 garrigue Relationship added related to 0006651


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker