www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5204] New: Inherited out contract requires lvalue result?

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5204

           Summary: Inherited out contract requires lvalue result?
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ah08010-d yahoo.com


--- Comment #0 from Austin Hastings <ah08010-d yahoo.com> 2010-11-11 16:04:09
PST ---
Using 2049, this code:
==========
module scratch;

interface collection( ValueT ) {
        alias collection!( ValueT ) collection_t;
        collection_t clear()
                out( result ) { assert( result.length == 0 ); }
         property size_t length();
}

interface mapping( KeyT, ValueT ) : collection!( ValueT ) { /* ... */ }

class aamap( KeyT, ValueT ) : mapping!( KeyT, ValueT ) {
        alias aamap!( KeyT, ValueT ) aamap_t;

        aamap_t clear( ) { return this; }
}

void main() {
        alias aamap!( string, int ) aa_str2int;
}
==========
produces these diagnostics:
==========
$ dmd -run scratch.d
scratch.d(15): Error: cast(collection)__result is not an lvalue
scratch.d(19): Error: template instance scratch.aamap!(string,int) error
instantiating
==========
As I understand it, I should be able to code a function like int foo() { return
1+1;} and have an out contract attached. So I don't understand why there is any
consideration of the result ever being an lvalue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 11 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5204


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #1 from bearophile_hugs eml.cc 2010-11-11 17:20:30 PST ---
This may be a reduced test case:


interface IFoo {
    IFoo bar()
        out {}
}
class Foo : IFoo {
    Foo bar() { return null; }
}
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 11 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5204


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

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


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2012-12-14 02:23:14 PST ---
https://github.com/D-Programming-Language/dmd/pull/1378

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 14 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5204



--- Comment #3 from github-bugzilla puremagic.com 2012-12-15 06:20:09 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/60862050c26158deebdaf5f0e8bae5a8650a7411
fix Issue 5204 - Inherited out contract requires lvalue result?

https://github.com/D-Programming-Language/dmd/commit/000253917c140a95c663a26848903e875877f82d
Merge pull request #1378 from 9rnsr/fix5204

Issue 5204 - Inherited out contract requires lvalue result?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 15 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5204


Kenji Hara <k.hara.pg gmail.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: -------
Dec 28 2012