Thread overview
[Issue 10953] New: Attribute inheritance needs to apply to contracts, too
Sep 03, 2013
Walter Bright
Sep 03, 2013
Kenji Hara
Sep 03, 2013
Walter Bright
September 03, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10953

           Summary: Attribute inheritance needs to apply to contracts, too
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bugzilla@digitalmars.com


--- Comment #0 from Walter Bright <bugzilla@digitalmars.com> 2013-09-02 21:21:24 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 03, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10953


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-09-02 21:45:07 PDT ---
(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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 03, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10953



--- Comment #2 from github-bugzilla@puremagic.com 2013-09-02 22:49:40 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 03, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10953


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------