Jump to page: 1 2
Thread overview
[Issue 3746] New: Misleding error message "OP has no effect in expression XXX), in void function
Jan 28, 2010
Witold Baryluk
Jan 28, 2010
Witold Baryluk
Jan 28, 2010
Bernard Helyer
Jan 28, 2010
Witold Baryluk
Jun 13, 2011
yebblies
Jun 13, 2011
yebblies
Jun 13, 2011
yebblies
[Issue 3746] Misleading error message "OP has no effect in expression XXX), in void function
Jun 13, 2011
yebblies
Jun 14, 2011
yebblies
Jun 14, 2011
Don
Jun 14, 2011
yebblies
Oct 10, 2011
yebblies
January 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3746

           Summary: Misleding error message "OP  has no effect in
                    expression XXX), in void function
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: baryluk@smp.if.uj.edu.pl


--- Comment #0 from Witold Baryluk <baryluk@smp.if.uj.edu.pl> 2010-01-27 17:15:05 PST ---
On function with void return type, if one will put expression after return:

void f() {
   auto a = 1, b = 3, c = 5;
   return a/b*c;
}


will end with compiler error like:

aaa.d(4): Error: * has no effect in expression (a / b * c)


My function "f" was lot bigger, and took me about 5 minutes to understand what is wrong.

Could such bugs can be detected and be something like

aaa.d(4): Error: no return statment allowed in void function/method

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3746


Witold Baryluk <baryluk@smp.if.uj.edu.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3746


Bernard Helyer <blood.of.life@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blood.of.life@gmail.com


--- Comment #1 from Bernard Helyer <blood.of.life@gmail.com> 2010-01-27 19:59:24 PST ---
Well, obviously return *is* allowed from void functions (void f() { return; }). But 'error: return statement with a value in a void function' would be a preferable message than talking about values having no effect in expressions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 28, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3746



--- Comment #2 from Witold Baryluk <baryluk@smp.if.uj.edu.pl> 2010-01-28 12:12:00 PST ---
(In reply to comment #1)
> Well, obviously return *is* allowed from void functions (void f() { return; }). But 'error: return statement with a value in a void function' would be a preferable message than talking about values having no effect in expressions.

Yes you are right. Error messages should be as precise as possible.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sky@q1cc.net


--- Comment #3 from yebblies <yebblies@gmail.com> 2011-06-12 23:18:47 PDT ---
*** Issue 3855 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #4 from yebblies <yebblies@gmail.com> 2011-06-12 23:19:46 PDT ---
*** This issue has been marked as a duplicate of issue 3630 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |
           Severity|minor                       |enhancement


--- Comment #5 from yebblies <yebblies@gmail.com> 2011-06-12 23:21:28 PDT ---
My bad, this is a request for a better error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746


bearophile_hugs@eml.cc changed:

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


--- Comment #6 from bearophile_hugs@eml.cc 2011-06-13 03:21:08 PDT ---
*** Issue 3922 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746



--- Comment #7 from bearophile_hugs@eml.cc 2011-06-13 03:22:41 PDT ---
Issue 3922 contains some interesting comments.

It seems this enhancement request for a better error message has many dupes!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Summary|Misleding error message "OP |Misleading error message
                   | has no effect in           |"OP  has no effect in
                   |expression XXX), in void    |expression XXX), in void
                   |function                    |function


--- Comment #8 from yebblies <yebblies@gmail.com> 2011-06-13 13:34:34 PDT ---
https://github.com/D-Programming-Language/dmd/pull/121

This adds the error message:
testx.d(4): Error: expression with no side effects used with void return

Good enough?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2