June 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746



--- Comment #9 from bearophile_hugs@eml.cc 2011-06-13 14:31:09 PDT ---
(In reply to comment #8)
> 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?

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: -------
June 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746



--- Comment #10 from yebblies <yebblies@gmail.com> 2011-06-13 22:21:03 PDT ---
(In reply to comment #9)
>
> 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

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: -------
June 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746



--- Comment #11 from bearophile_hugs@eml.cc 2011-06-14 05:14:02 PDT ---
(In reply to comment #10)

> 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.

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: -------
June 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.au


--- Comment #12 from Don <clugdbug@yahoo.com.au> 2011-06-14 05:19:10 PDT ---
(In reply to comment #10)
> (In reply to comment #9)
> >
> > 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

Yes, 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: -------
June 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746



--- Comment #13 from yebblies <yebblies@gmail.com> 2011-06-14 08:51:36 PDT ---
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: -------
October 10, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=3746


yebblies <yebblies@gmail.com> changed:

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


--- Comment #14 from yebblies <yebblies@gmail.com> 2011-10-10 13:22:15 EST ---
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: -------
1 2
Next ›   Last »