Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007884OCamllanguage featurespublic2018-12-21 17:252019-01-04 18:20
Reporteryallop 
Assigned Toyallop 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusresolvedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0007884: "module rec" does not allow constraints on the first module
DescriptionThis is allowed in a signature:

  module rec X : T
         and Y : T with type t = int

and this is allowed, too:

  module rec X : T with type t = int [@@foo]
         and Y : T

but this is currently rejected as a syntax error:

  module rec X : T with type t = int
         and Y : T
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0019514)
lpw25 (developer)
2018-12-21 17:38

This comes from the potential ambiguity with:

    module rec X : T with type t = int
                       and type t = int

that is resolved in favour of shifting the `and`.

It can be avoided using parentheses:

    module rec X : (T with type t = int)
           and Y : T

I think that avoiding the conflict isn't really possible in an LR(1) grammar because you'd need to know whether to shift or reduce the `and` without looking at the `Y`. Maybe you could extensively re-engineer the grammar so that the conflict was avoided, but I suspect its quite difficult to do so.
(0019515)
yallop (developer)
2018-12-21 17:55

Ah, this is already noted in the manual!

> Note that, in the specification case, the module-types must be parenthesized if they use the with mod-constraint construct.

It could be made a bit more precise, I suppose, by mentioning that the parentheses aren't needed on the last member in the group, but it hardly seems worth it.

- Issue History
Date Modified Username Field Change
2018-12-21 17:25 yallop New Issue
2018-12-21 17:38 lpw25 Note Added: 0019514
2018-12-21 17:55 yallop Note Added: 0019515
2018-12-21 20:30 yallop Status new => resolved
2018-12-21 20:30 yallop Resolution open => no change required
2018-12-21 20:30 yallop Assigned To => yallop


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker