Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006331OCamltypingpublic2014-02-18 17:542015-12-11 19:25
Assigned Togarrigue 
PlatformOSOS Version
Product Version4.01.0 
Target VersionFixed in Version4.02.0+dev 
Summary0006331: `is_fixed_type` does not take account of nested aliases
DescriptionThe `is_fixed_type` function in "" does not take account of nested
aliases. For example,

     # type t = private < x : int; .. > as 'a;;
     type t = private < x : int; .. >
     # type t = private (< x : int; .. > as 'a) as 'a;;
     Characters 5-46:
       type t = private (< x : int; .. > as 'a) as 'a;;
     Error: A type variable is unbound in this type declaration.
     In type < x : int; .. > as 'a the variable 'a is unbound

and probably more concerning

     # type t = private < x : int > as 'a;;
     Characters 5-34:
       type t = private < x : int > as 'a;;
     Error: This fixed type has no row variable
     # type t = private (< x : int > as 'a) as 'b;;
     type t = private < x : int >
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
garrigue (manager)
2014-02-19 03:30

Actually, the problem is rather that the distinction between private abbreviations and private row types is made on a purely syntactic, and you get an error if the system guessed wrong. I agree that the guessing could be improved: in your example the object type has syntactically no row variable, so both cases should succeed; symmetrically, having several aliases should not change the behavior (but I'm not sure why one would want to pile up aliases in this way).
Note that one can already force a private abbreviation by using a constraint:
  type t = private 'a constraint 'a = <x:int>

Another approach would be to do it more semantically: produce a private row type if the type has an unbound row, independently of the syntax. The problem is that it might behave in unexpected ways: a type that syntactically it looks like a private row type could end up generating a private abbreviation.
For instance the following is already accepted
  type 'a t = <x:'a> as 'a
  type u = private 'b constraint 'b = <x:'b t; ..>
and the semantic approach would allow
  type u = <x:'b t; ..> as 'b
garrigue (manager)
2014-02-25 09:19

Fixed in trunk at revision 14443, following the "Another approach".
Now all for cases are accepted, creating a private abbreviation or a private row depending of whether .. is used or not ('as' doesn't matter).

- Issue History
Date Modified Username Field Change
2014-02-18 17:54 lpw25 New Issue
2014-02-19 03:30 garrigue Note Added: 0010944
2014-02-25 09:19 garrigue Note Added: 0010978
2014-02-25 09:19 garrigue Status new => resolved
2014-02-25 09:19 garrigue Fixed in Version => 4.02.0+dev
2014-02-25 09:19 garrigue Resolution open => fixed
2014-02-25 09:19 garrigue Assigned To => garrigue
2015-12-11 19:25 xleroy Status resolved => closed
2017-02-23 16:45 doligez Category OCaml typing => typing

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker