www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3478] New: "no effect in expression" error on return to void

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

           Summary: "no effect in expression" error on return to void
           Product: D
           Version: 1.051
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: moritzwarning web.de



PST ---
void foo() { return 0; }

this code gives

main.d(24): Error: long has no effect in expression (0)

iirc, it should be valid.

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


Walter Bright <bugzilla digitalmars.com> changed:

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



18:55:45 PST ---
I'd actually like that to be the new behavior, as any other behavior (I tried
them) caused worse problems. The good news is it's an easy fix for the code.

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




PST ---
You should change the spec in this case:

http://www.digitalmars.com/d/1.0/statement.html


"Expression is allowed even if the function specifies a void return type. The
Expression will be evaluated, but nothing will be returned."

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




PST ---
fwiw, the new behavior makes sense to me.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au




 You should change the spec in this case:
 
 http://www.digitalmars.com/d/1.0/statement.html
 
 
 "Expression is allowed even if the function specifies a void return type. The
 Expression will be evaluated, but nothing will be returned."
It's still true. This works, for example: void foo() { return bar(); } It's exactly the same as: { bar(); return; } which is OK. Likewise, return 0; becomes { 0; return; } which is generating the "no effect" error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 05 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3478




02:31:19 PST ---
I'll change the spec to say that it's illegal to have a void return expression
with no side effects.

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


Walter Bright <bugzilla digitalmars.com> changed:

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



00:54:03 PST ---
Fixed dmd 2.037

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