Bug 14988 – Looks like inconsistent error report for the pointless in-contract definition

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-08-31T15:10:19Z
Last change time
2024-12-13T18:44:25Z
Assigned to
No Owner
Creator
Kenji Hara
Moved to GitHub: dmd#19035 →

Comments

Comment #0 by k.hara.pg — 2015-08-31T15:10:19Z
Compiler reports an error for Foo1.foo, but not for Foo2.foo. class Obj1 { string foo() { return ""; } } class Obj2 { string foo(); } class Foo1 : Obj1 { // Error: function test.Foo1.foo cannot have an in contract // when overriden function test.Obj1.foo does not have an in contract override string foo() in { } body { return "foo"; } } class Foo2 : Obj2 { // no error override string foo() in { } body { return "foo"; } } ---- The original mention is here: http://forum.dlang.org/post/[email protected] With 2.067.x, following code had worked without any errors, but with 2.068.1, it makes an error. class Foo { override string toString() in { } body { return "foo"; } } That's introduced by the druntime change that to directly use object.d than object.di file.
Comment #1 by doob — 2015-09-01T06:29:52Z
I wouldn't say the in-contract is pointless, it's a minimal test case. The original code of course has code in the in-contract.
Comment #2 by dfj1esp02 — 2015-09-01T08:08:46Z
Comment #3 by dlang-bugzilla — 2015-09-01T12:15:38Z
(In reply to Kenji Hara from comment #0) > Compiler reports an error for Foo1.foo, but not for Foo2.foo. FWIW - before DMD commit 0ab7722db17351cc8db67f54f36cdb85387bd1d7, the code compiled successfully.
Comment #4 by dlang-bugzilla — 2015-09-01T12:16:34Z
Comment #5 by dlang-bugzilla — 2015-09-01T12:18:06Z
> Issue 6242 - Disallow inoperant "in" contracts No problem here I guess.
Comment #6 by robert.schadek — 2024-12-13T18:44:25Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19035 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB