Bug 20885 – pointer rejected for the variable declared in a `if` condition

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-05-30T20:58:20Z
Last change time
2020-05-31T04:35:04Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Basile-z

Comments

Comment #0 by b2.temp — 2020-05-30T20:58:20Z
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.
Comment #1 by b2.temp — 2020-05-30T21:00:44Z
that's a regression: > 2.061 to 2.084.1: Success and no output > Since 2.085.1: Failure with output: onlineapp.d(7): Error: found `*` while expecting `=` or identifier
Comment #2 by b2.temp — 2020-05-30T21:48:10Z
caused by myself: --- digger: Finding shortest path between 12bb06c30584c93ef63417889d575f8ad6b2c5df and de173efe9ad320a3a56d7beab59743cd8b959975... digger: 0 commits (about 0 tests) remaining. digger: de173efe9ad320a3a56d7beab59743cd8b959975 is the first bad commit commit de173efe9ad320a3a56d7beab59743cd8b959975 Author: Nicholas Wilson <[email protected]> Date: Wed Mar 13 07:25:30 2019 +0800 dmd: Merge pull request #9447 from Basile-z/issue-19730 https://github.com/dlang/dmd/pull/9447 [trivial] fix issue 19730 - if (auto x) {} isn't properly rejected diff --git a/dmd b/dmd index 2eccd9281..5c3d5701b 160000 --- a/dmd +++ b/dmd @@ -1 +1 @@ -Subproject commit 2eccd928103b17c9c2b3c9415e34619cc8abed78 +Subproject commit 5c3d5701b02a72d1ae65a059fdcbfb528fc7b82b digger: Bisection completed successfully. ---
Comment #3 by dlang-bot — 2020-05-30T22:37:12Z
@NilsLankila created dlang/dmd pull request #11201 "fix issue 20885 - pointer rejected for the variable declared in a `if…" fixing this issue: - fix issue 20885 - pointer rejected for the variable declared in a `if` condition https://github.com/dlang/dmd/pull/11201
Comment #4 by dlang-bot — 2020-05-31T04:35:04Z
dlang/dmd pull request #11201 "fix issue 20885 - pointer rejected for the variable declared in a `if…" was merged into stable: - 4756bdf98f79fa333bddccb4bdeeed3e8971369c by Nils Lankila: fix issue 20885 - pointer rejected for the variable declared in a `if` condition https://github.com/dlang/dmd/pull/11201