|Anonymous | Login | Signup for a new account||2017-03-26 13:19 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006934||OCaml||typing||public||2015-07-21 17:42||2017-03-16 00:38|
|Target Version||Fixed in Version||4.06.0+dev|
|Summary||0006934: nonrec misbehaves with GADTs|
|Description||Consider 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.
|Tags||No tags attached.|
|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.|
@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".
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.
|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.|
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.
|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|