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


--- Comment #0 from Moritz Warning <moritzwarning web.de> 2009-11-05 16:26:18
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


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2009-11-05
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



--- Comment #2 from Moritz Warning <moritzwarning web.de> 2009-11-05 19:21:30
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



--- Comment #3 from Moritz Warning <moritzwarning web.de> 2009-11-05 19:23:17
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


--- Comment #4 from Don <clugdbug yahoo.com.au> 2009-11-05 21:42:48 PST ---
(In reply to comment #2)
 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



--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2009-11-30
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


--- Comment #6 from Walter Bright <bugzilla digitalmars.com> 2009-12-06
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