www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21590] New: assignment inside assert accepted if

https://issues.dlang.org/show_bug.cgi?id=21590

          Issue ID: 21590
           Summary: assignment inside assert accepted if
                    -checkaction=context is given
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: kdevel vogtner.de

```assgncnd.d
unittest {
   int a, b = 1;
   assert (a = b);
}
```

$ dmd -unittest -main -run assgncnd.d 
assgncnd.d(3): Error: assignment cannot be used as a condition, perhaps == was
meant?

$ dmd -unittest -checkaction=context -main -run assgncnd.d 
1 modules passed unittests

Tested DMD Versions:

2.095.0 bad
2.093.1 bad
2.090.1 good

--
Jan 28