Bug 10953 – Attribute inheritance needs to apply to contracts, too

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-02T21:21:00Z
Last change time
2013-09-02T22:49:54Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2013-09-02T21:21:24Z
Kenji reports: class Foo { void func() nothrow pure @safe in {} out {} body {} } class Bar : Foo { override void func() // inherits attributes of Foo.func in {} out {} body {} } Bar.func reports "cannot call xxx function" error. The reason is the two calls of findVtblIndex in FuncDeclaration::semantic. It would modify the type field if a derived method inherits the attributes of its base method (This is documented behavior. Read http://dlang.org/function#virtual-functions if you interest). But it is not reflected to the local variable TypeFunction *f See also https://github.com/D-Programming-Language/dmd/pull/2516
Comment #1 by k.hara.pg — 2013-09-02T21:45:07Z
(In reply to comment #0) > Kenji reports: > > class Foo > { > void func() nothrow pure @safe > in {} out {} body {} > } > > class Bar : Foo > { > override void func() // inherits attributes of Foo.func > in {} out {} body {} > } > > > Bar.func reports "cannot call xxx function" error. > The reason is the two calls of findVtblIndex in FuncDeclaration::semantic. It > would modify the type field if a derived method inherits the attributes of its > base method (This is documented behavior. Read > http://dlang.org/function#virtual-functions if you interest). But it is not > reflected to the local variable TypeFunction *f > > See also https://github.com/D-Programming-Language/dmd/pull/2516 The bug occurs when -profile switch is specified. Compiler fix: https://github.com/D-Programming-Language/dmd/pull/2521
Comment #2 by github-bugzilla — 2013-09-02T22:49:40Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/44d95dda97870d372c3c7246cf21e614c72e2a61 fix Issue 10953 - Attribute inheritance needs to apply to contracts, too https://github.com/D-Programming-Language/dmd/commit/a4d5392763e90ff4400495030a2cec8b498d3908 Merge pull request #2521 from 9rnsr/fix10953 Issue 10953 - Attribute inheritance needs to apply to contracts, too