Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005815OCamlOCaml typingpublic2012-11-07 19:482013-07-16 11:21
Reporterlpw25 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target Version4.01.0+devFixed in Version4.01.0+dev 
Summary0005815: Multiple exceptions in signatures gives an error
DescriptionMultiple 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 = <here>
         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

TagsNo tags attached.
Attached Filesdiff file icon exceptions.diff [^] (2,180 bytes) 2012-11-07 19:48 [Show Content]

- Relationships

-  Notes
(0008693)
doligez (administrator)
2013-01-04 15:20

I would rather align everything on the behaviour of types:

  # module type S = sig type t = A type t = A end;;
  Error: Multiple definition of the type name t.
         Names must be unique in a given structure or signature.

But I don't know what reasoning led to accepting multiple values in the first place.

At the very least, the error message should be fixed.

(0008729)
lpw25 (developer)
2013-01-09 17:50
edited on: 2013-01-09 17:51

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.

(0009435)
xleroy (administrator)
2013-06-07 16:22

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.
(0009525)
garrigue (manager)
2013-06-17 03:52

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.
(0009526)
garrigue (manager)
2013-06-17 04:04

Applied the patch in 4.01 and trunk, revisions 13788 and 13789.

I'm aware that having two exceptions with the same name in the same module is a very bad idea, but that problem is not about signatures.

- Issue History
Date Modified Username Field Change
2012-11-07 19:48 lpw25 New Issue
2012-11-07 19:48 lpw25 File Added: exceptions.diff
2013-01-04 15:20 doligez Note Added: 0008693
2013-01-04 15:20 doligez Status new => acknowledged
2013-01-04 15:20 doligez Target Version => 4.01.0+dev
2013-01-09 17:50 lpw25 Note Added: 0008729
2013-01-09 17:51 lpw25 Note Edited: 0008729 View Revisions
2013-01-09 17:51 lpw25 Note Edited: 0008729 View Revisions
2013-06-07 16:22 xleroy Note Added: 0009435
2013-06-17 03:52 garrigue Note Added: 0009525
2013-06-17 04:04 garrigue Note Added: 0009526
2013-06-17 04:04 garrigue Status acknowledged => resolved
2013-06-17 04:04 garrigue Fixed in Version => 4.01.0+dev
2013-06-17 04:04 garrigue Resolution open => fixed
2013-06-17 04:04 garrigue Assigned To => garrigue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker