Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006934OCamltypingpublic2015-07-21 17:422017-03-16 00:38
Reportermottl 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.02.2 
Target VersionFixed in Version4.06.0+dev 
Summary0006934: nonrec misbehaves with GADTs
DescriptionConsider the following example:

  type nonrec t = A : t

The above will fail with an unbound type constructor for "t". But it isn't really a recursive type, it's a GADT. I think "nonrec" shouldn't apply to the return type of a GADT, at least not to the outermost type constructor defining the GADT, though possibly to types in its parameters.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0014238)
dim (developer)
2015-07-22 11:31

I'd be in favor of just updating the error message to say that you can't use [nonrec] when defining a GADT. I don't like the idea of allowing [type nonrec t = A : t -> t] where the last two [t]s means two different things.
(0014245)
mottl (reporter)
2015-07-22 22:26

@dim I agree that the syntax of GADTs doesn't compose nicely with "nonrec" here, and we don't want to break existing syntax. Maybe it would have been better to do something like:

  type t as u = t * u

where the "t" on the RHS refers to the previous definition of "t", and "u" is the recursive alias for the current definition of "t".
(0017646)
garrigue (manager)
2017-03-14 10:41

My understanding is that nonrec is essentially intended for type abbreviations.
So is its not working with GADTs really a problem?
I tend to concur with @dim.
(0017676)
mottl (reporter)
2017-03-15 15:34

It's surely not a big problem. It's conceivable that a developer has opened a module and just wants to define type "t" in terms of a type "t" in the opened module. Though dropping "nonrec" and using an explicit module path would easily solve the issue, the error message will likely confuse the developer.
(0017682)
garrigue (manager)
2017-03-16 00:38

Fixed in commit f9008883 by introducing a new error message:

type nonrec t = A : t;;
Line _, characters 16-21:
Error: GADT case syntax cannot be used in a 'nonrec' block.

- Issue History
Date Modified Username Field Change
2015-07-21 17:42 mottl New Issue
2015-07-22 11:31 dim Note Added: 0014238
2015-07-22 15:24 doligez Status new => acknowledged
2015-07-22 15:24 doligez Target Version => 4.03.0+dev / +beta1
2015-07-22 22:26 mottl Note Added: 0014245
2016-04-15 15:52 doligez Target Version 4.03.0+dev / +beta1 => 4.03.1+dev
2017-02-16 14:01 doligez Target Version 4.03.1+dev => undecided
2017-02-23 16:45 doligez Category OCaml typing => typing
2017-03-14 10:41 garrigue Note Added: 0017646
2017-03-15 15:26 doligez Target Version undecided =>
2017-03-15 15:34 mottl Note Added: 0017676
2017-03-16 00:38 garrigue Note Added: 0017682
2017-03-16 00:38 garrigue Status acknowledged => resolved
2017-03-16 00:38 garrigue Fixed in Version => 4.06.0+dev
2017-03-16 00:38 garrigue Resolution open => fixed
2017-03-16 00:38 garrigue Assigned To => garrigue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker