www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12390] New: "has no effect in expression" diagnostic regression

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

           Summary: "has no effect in expression" diagnostic regression
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thecybershadow gmail.com



13:25:39 EET ---
///////// test.d ////////
struct S { int i; }

S fun() { return S(42); }

void main()
{
    fun().i == 4;
}
/////////////////////////

DMD 2.065: 
test.d(7): Error: == has no effect in expression (fun().i == 4)

DMD master compiles.

Introduced in https://github.com/D-Programming-Language/dmd/pull/3186

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 17 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12390


Kenji Hara <k.hara.pg gmail.com> changed:

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



This is not a regression. Rather the behavior change was an actual fix of
rejects-valid bug.


 DMD 2.065: 
 test.d(7): Error: == has no effect in expression (fun().i == 4)
'fun' is not pure, so essentially its call could have side effect. So the error message was incorrect in 2.065 and earlier.
 DMD master compiles.
Therefore, current git-head behavior is correct. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 29 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12390


Vladimir Panteleev <thecybershadow gmail.com> changed:

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



11:30:04 EET ---
Even if fun is not pure, the code performs two redundant operations (obtaining
a field of the result, then comparing it to something).

fun();

This should compile.

fun().i == 4;

This should not.

 Rather the behavior change was an actual fix of rejects-valid bug.
In a [Refactoring] pull request? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 29 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12390




11:40:27 EET ---
I should note that the error WAS working as intended - this was a bug in my
code, I intended to write "fun().i = 4" (the function returned by ref in my
code), but did not catch the bug until I spotted it accidentally. So this is
definitely a regression which affects real use cases.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 29 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12390


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
            Summary|Regression (2.065): "has no |[REG2.066a] "has no effect
                   |effect in expression"       |in expression" diagnostic
                   |diagnostic regression       |regression



OK, I confirmed the issue. It's a bug in the value discarding check.

And, this is 2.066 git-head only regression.

https://github.com/D-Programming-Language/dmd/pull/3432

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 07 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12390




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/89ca0a14eb2b0a3e232a2eded5f43693d02510e3
fix Issue 12390 - "has no effect in expression" diagnostic regression

When value discarding check on statements, the side-effect check should not be
done deeply.

https://github.com/D-Programming-Language/dmd/commit/b80a6da17ac42c8976f5e552faff1b969593bdc0


[REG2.066a] Issue 12390 - "has no effect in expression" diagnostic regression

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 07 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12390


Kenji Hara <k.hara.pg gmail.com> changed:

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


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 07 2014