Bug 12740 – DMD accepts invalid version syntax

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-05-13T00:16:00Z
Last change time
2014-05-29T02:51:16Z
Keywords
pull, spec
Assigned to
nobody
Creator
briancschott
Blocks
10233

Comments

Comment #0 by briancschott — 2014-05-13T00:16:25Z
From the vibe.d source: ------ version (VibeCustomMain) {} else: ------ The language specification does not say that "else:" is valid, and it is not consistent with the normal usage of "else". If you try this with a normal else block, the compiler correctly gives the error message "Error: found ':' instead of statement".
Comment #1 by andrej.mitrovich — 2014-05-13T10:30:10Z
Seems like more of a spec issue than accepts-invalid to me. Disallowing this would break a ton of code for no benefit.
Comment #2 by k.hara.pg — 2014-05-29T02:21:37Z
The issue is in the definition of ConditionalDeclaration. $(GNAME ConditionalDeclaration): $(GLINK Condition) $(GLINK DeclarationBlock) $(GLINK Condition) $(GLINK DeclarationBlock) $(D else) $(GLINK DeclarationBlock) $(GLINK Condition) $(D :) $(GLINK DeclDefs)$(OPT) In here, `version(id): ...` is explicitly allowed but `version(id) ... else:` is not. To fix the issue, ConditionalDeclaration should have following additional grammar. $(GLINK Condition) $(GLINK DeclarationBlock) $(D else) $(D :) $(GLINK DeclDefs)$(OPT)
Comment #3 by k.hara.pg — 2014-05-29T02:23:47Z
*** Issue 12818 has been marked as a duplicate of this issue. ***
Comment #4 by k.hara.pg — 2014-05-29T02:25:22Z
Comment #5 by github-bugzilla — 2014-05-29T02:51:16Z
Commits pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/e019100dccae406a4645958257b7f1beed5d41dc fix Issue 12740 - DMD accepts invalid version syntax https://github.com/D-Programming-Language/dlang.org/commit/91ae601f7d9278ea40be1c7bdbbb3b835c51ecf3 Merge pull request #585 from 9rnsr/fix12740 Issue 12740 - DMD accepts invalid version syntax