[Issue 20885] New: pointer rejected for the variable declared in a `if` condition

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 30 20:58:20 UTC 2020


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

          Issue ID: 20885
           Summary: pointer rejected for the variable declared in a `if`
                    condition
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

according to the grammar this should be accepted:

---
void main()
{
    alias P  = void*;
    alias PP = void**;
    PP[1] a  = null;
    if (const void** b = a[0]){} // OK
    if (const P*     b = a[0]){} // NG
}
---

but when an identifier is used as BasicType then the
Declarator.VarDeclarator.BasicType2 (i.e the star) is rejected by the parser.

--


More information about the Digitalmars-d-bugs mailing list