digitalmars.D.bugs - [Issue 3746] New: Misleding error message "OP has no effect in expression XXX), in void function
- d-bugmail puremagic.com (28/28) Jan 27 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (8/8) Jan 27 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (12/12) Jan 27 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (7/10) Jan 28 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (10/10) Jun 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (12/12) Jun 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (12/12) Jun 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (10/10) Jun 13 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (7/7) Jun 13 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (17/17) Jun 13 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (11/17) Jun 13 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (12/18) Jun 13 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (28/31) Jun 14 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (12/24) Jun 14 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (12/12) Jun 14 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
- d-bugmail puremagic.com (12/12) Oct 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3746
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 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: -------
Jan 27 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: -------
Jan 27 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 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: -------
Jan 27 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3746 12:12:00 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.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: -------
Jan 28 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3746 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sky q1cc.net *** 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: -------
Jun 12 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 *** 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: -------
Jun 12 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 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: -------
Jun 12 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc *** 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: -------
Jun 13 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746 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: -------
Jun 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 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: -------
Jun 13 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746https://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?I don't understand. Elsewhere I have a bug report that asks for a new error message if you don't use the result of a pure function. But this bug report just asks for a better error message in the situation of using "return x;" in a void function. So I expected an error message like: foo.d(20): Error: a void function can't return 'int'. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 13 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746I don't understand. Elsewhere I have a bug report that asks for a new error message if you don't use the result of a pure function. But this bug report just asks for a better error message in the situation of using "return x;" in a void function. So I expected an error message like: foo.d(20): Error: a void function can't return 'int'.Returning an int expression from a void function is perfectly legal, so long as the expression has side effects. This is explicitly allowed by the spec. http://www.digitalmars.com/d/2.0/statement.html#ReturnStatement You're talking about two completely separate issues, both of which are enhancements. This issue is about providing a clearer error message without changing the spec. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 13 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746You're talking about two completely separate issues, both of which are enhancements. This issue is about providing a clearer error message without changing the spec.Walter has accepted one of the enhancement requests I was talking about (the one about pure functions). I was not aware the second too is an enhancement request, but after re-reading that part of the D specs I see you are right. So technically your error message is correct. But it's hard to keep in memory all the D specs, especially for D newbies. So I suggest a longer and more wordy error message, because this error message is not easy enough to understand. ---------- According to the D specs this code is illegal, is your patch raising an error on it? pure int sqr(int x) { return x * x; } void main() { return sqr(10); } ---------- According to the current D specs this code is correct: int sqr(int x) { return x * x; } void main() { return sqr(10); } But I can't see this as correct, it's bug prone. So bug 3922 was not a dupe, it was an ehancement request! I have to reopen it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 14 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.auYes, but it was agreed on the newsgroup that this is a misfeature. (Andrei was horrified about it). It should be disallowed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------I don't understand. Elsewhere I have a bug report that asks for a new error message if you don't use the result of a pure function. But this bug report just asks for a better error message in the situation of using "return x;" in a void function. So I expected an error message like: foo.d(20): Error: a void function can't return 'int'.Returning an int expression from a void function is perfectly legal, so long as the expression has side effects. This is explicitly allowed by the spec. http://www.digitalmars.com/d/2.0/statement.html#ReturnStatement
Jun 14 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746 Without this feature, what should happen with lazy void? void lf(lazy void a) { a; } void main() { int i; lf(i++); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 14 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |FIXED This bug has been fixed with issue 5399. https://github.com/D-Programming-Language/dmd/commit/c942d51c8b1103d5ce4c3dfc03ae77c07c687cd6 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 09 2011