Bug 19225 – Confusing error message on `static else`

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-09-05T17:16:38Z
Last change time
2018-09-07T13:11:15Z
Assigned to
No Owner
Creator
Elias Batek (0xEAB)

Comments

Comment #0 by desisma — 2018-09-05T17:16:38Z
Of course, it's just `else` and there's no `static else`, but the compiler won't really help one in case one assumed `static else` is fine. Motivation: This happened to someone on a Dlang-related Discord server today. Well, to be honest, it happened to me when I used `static if` for the first time, too. Current state: rdmd --compiler=dmd --eval="static if(false){}static else {}" /tmp/.rdmd-1000/eval.FE84D13526EC0E678549134C9377EB0E.d(18): Error: basic type expected, not else Solution: Let the compiler hint at the fact it's just `else`.
Comment #1 by desisma — 2018-09-05T17:25:50Z
Comment #2 by github-bugzilla — 2018-09-07T13:11:14Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/d01a82be09e7f98ae960658ce61e863b90101625 Fix issue 19225 - Confusing error message on `static else` So users assuming `static else` is fine get a helpful error message. https://github.com/dlang/dmd/commit/497f07b341208e23539f97dfaf0b8a643448ccc0 Merge pull request #8666 from 0xEAB/master Fix issue 19225 - Confusing error message on `static else`