Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006035OCamlOCaml typingpublic2013-06-07 16:352013-06-13 15:52
Reporterfrisch 
Assigned Tofrisch 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.01.0+dev 
Summary0006035: Multiple declarations of the same method in the same object should be rejected
Descriptionlet c = object
  method x = 0
  method x = 0
end

is currently accepted, and trigger the warning 7 (method x is overridden) on the second occurrence. I propose to consider it an error when a method overrides another method defined in the same object (which is thus useless), even the method is marked with "!".

We have been bitten by not having the compiler complain on a code like:

 let c = object
    inherit super_class

    method! init = ...
  
    ...
    ...

    method! init = ...
 end


The proposed change is not difficult to implement, but it could potentially break existing (bad) code. We could also create a new warning, but since it will report code which is clearly wrong and trivial to fix, it would make more sense to have an error.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0009437)
frisch (developer)
2013-06-07 17:37

Commit 13756 in trunk.
(0009438)
frisch (developer)
2013-06-07 17:37

Keeping this open for a few days, in case anyone wants to complain.
(0009463)
frisch (developer)
2013-06-12 17:12

Nobody complained. The new behavior is documented in the manual.
(0009479)
dsheets (reporter)
2013-06-13 15:23
edited on: 2013-06-13 15:50

Personally, I believe this error is a good idea. With that said, this will cause breakage in some libraries with (benign) method duplication. For instance, ocamlnet 3.6.0, 3.6.3, and 3.6.5 have identical 'stat' methods in netpop. See https://github.com/OCamlPro/opam-repository/pull/796 [^] for more info and the OPAM patch.

I'm not really sure what you'll do with this information but gasche told me to report here for your edification. Also, there was some speculation about this sort of problem being caused by a silent merge bug.

Gerd has also been notified via ocamlnet-devel.

(0009480)
dsheets (reporter)
2013-06-13 15:31

Bah! Clearly that URL should not end with ">" as that's an invalid character for a URI, Mantis regex.
(0009481)
frisch (developer)
2013-06-13 15:52

Thanks for the information. I see it as a good think that the compiler spots the problem, especially since the fix is trivial.

- Issue History
Date Modified Username Field Change
2013-06-07 16:35 frisch New Issue
2013-06-07 17:37 frisch Note Added: 0009437
2013-06-07 17:37 frisch Assigned To => frisch
2013-06-07 17:37 frisch Status new => assigned
2013-06-07 17:37 frisch Note Added: 0009438
2013-06-07 17:37 frisch Fixed in Version => 4.01.0+dev
2013-06-12 17:12 frisch Note Added: 0009463
2013-06-12 17:12 frisch Status assigned => resolved
2013-06-12 17:12 frisch Resolution open => fixed
2013-06-13 15:23 dsheets Note Added: 0009479
2013-06-13 15:31 dsheets Note Added: 0009480
2013-06-13 15:50 frisch Note Edited: 0009479 View Revisions
2013-06-13 15:52 frisch Note Added: 0009481


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker