You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5815 Reporter:@lpw25 Assigned to:@garrigue Status: closed (set by @xavierleroy on 2015-12-11T18:21:00Z) Resolution: fixed Priority: normal Severity: minor Target version: 4.01.0+dev Fixed in version: 4.01.0+dev Category: typing Monitored by:@hcarty
Bug description
Multiple exceptions with the same name in a signature causes an error:
module type S = sig exception Foo exception Foo end;;
Characters -1--1:
module type S = sig exception Foo exception Foo end;;
Error: Module type declarations do not match:
module type S = sig exception Foo exception Foo end
does not match
module type S = sig exception Foo exception Foo end
At position module type S =
Illegal permutation of structure fields
This is not consistent with the behaviour of structures:
module M = struct exception Foo exception Foo end;;
module M : sig exception Foo end
The attached patch fixes this, so that multiple exceptions with the same name behave just like multiple values with the same name:
module type S = sig exception Foo exception Foo end;;
I suggested aligning the behaviour of exceptions with the behaviour of values within signatures because their behaviours are aligned within structures.
I imagine multiple values are allowed in signatures because multiple values are allowed in structures.
This makes automated generation of signatures from structures easier.
The error message is weird indeed. Note that 3.12 accepts this signature without errors, but (probably) no structure matches it. So, this is a fairly recent change.
Actually not only this signature was accepted in 3.12, but it also matched the module
struct exception Foo end
On the other hand,
sig exception Foo of int exception Foo of bool end
doesn't match any module.
But there seems to be no good reason for such a restriction only on signatures,
whereas structures are accepted.
Original bug ID: 5815
Reporter: @lpw25
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:21:00Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.01.0+dev
Fixed in version: 4.01.0+dev
Category: typing
Monitored by: @hcarty
Bug description
Multiple exceptions with the same name in a signature causes an error:
module type S = sig exception Foo exception Foo end;;
Characters -1--1:
module type S = sig exception Foo exception Foo end;;
Error: Module type declarations do not match:
module type S = sig exception Foo exception Foo end
does not match
module type S = sig exception Foo exception Foo end
At position module type S =
Illegal permutation of structure fields
This is not consistent with the behaviour of structures:
module M = struct exception Foo exception Foo end;;
module M : sig exception Foo end
The attached patch fixes this, so that multiple exceptions with the same name behave just like multiple values with the same name:
module type S = sig exception Foo exception Foo end;;
module type S = sig exception Foo end
File attachments
The text was updated successfully, but these errors were encountered: