Bug 13362 – DMD accepts body-less switch

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-22T21:57:18Z
Last change time
2024-12-13T18:24:42Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Orvid King
Moved to GitHub: dmd#18872 →

Comments

Comment #0 by blah38621 — 2014-08-22T21:57:18Z
DMD currently accepts a switch with no actual body (extracted from a parital dustmite reduction): switch( ch ) return ; As a likely directly related issue, DMD also accepts this, although it shouldn't: IRCallingConvention parseCallConvention() { // CallConvention switch(tok) { return IRCallingConvention.d; } }
Comment #1 by yebblies — 2014-08-23T15:41:20Z
These are unfortunately valid, and relied upon for this: switch(...) with(...) { }
Comment #2 by ibuclaw — 2014-08-23T16:04:09Z
(In reply to yebblies from comment #1) > These are unfortunately valid, and relied upon for this: > > switch(...) with(...) > { > } Any other valid cases? It might seem reasonable to clamp down on just what is accepted. Also accepted code. switch(ch) with(obj) return;
Comment #3 by b2.temp — 2021-01-04T00:46:05Z
switch (a) static foreach (c, list) case c: mixin(gencodefor!c);
Comment #4 by robert.schadek — 2024-12-13T18:24:42Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18872 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB