Thread overview
[Issue 3390] New: [tdpl] out(result) contract should not be able to rebind result
Oct 19, 2009
Don
Nov 21, 2009
Walter Bright
Nov 22, 2009
Leandro Lucarella
Dec 06, 2009
Walter Bright
October 12, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3390

           Summary: [tdpl] out(result) contract should not be able to
                    rebind result
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrei@metalanguage.com


--- Comment #0 from Andrei Alexandrescu <andrei@metalanguage.com> 2009-10-12 15:45:51 PDT ---
This code compiles and runs:

int fun()
out(result) { result = 2; }
body { return 1; }

However, fun still returns 1 (presumably because "result" is a copy of what
body returned).

The compiler should disallow flat out rebinding of result.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 19, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3390


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2009-10-19 04:13:13 PDT ---
PATCH: Why not just make 'result' const?

// func.c, line 1030.

           v = new VarDeclaration(loc, type->nextOf(), outId, NULL);
               v->noauto = 1;
#if DMDV2
+               v->storage_class |= STCconst;
               if (f->isref)
               {
                   v->storage_class |= STCref | STCforeach;
               }
#endif

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 21, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3390


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2009-11-21 03:48:16 PST ---
Will only fix for D2, since D1 hasn't a good notion of const.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 22, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3390


Leandro Lucarella <llucax@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |llucax@gmail.com


--- Comment #3 from Leandro Lucarella <llucax@gmail.com> 2009-11-22 14:39:13 PST ---
SVN commit: http://www.dsource.org/projects/dmd/changeset/259

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 06, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3390


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2009-12-06 00:53:00 PST ---
Fixed dmd 2.037

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