if(1)
asm {};
else
asm {};
Error: found 'else' instead of statement
Error: unrecognized declaration
Comment #1 by k.hara.pg — 2013-08-13T05:16:44Z
http://dlang.org/statement.html
Statement:
NonEmptyStatement
NonEmptyStatement:
NonEmptyStatementNoCaseNoDefault
NonEmptyStatementNoCaseNoDefault:
AsmStatement
AsmStatement:
asm { }
asm { AsmInstructionList }
AsmStatement does not take semicolon at the end, then
if(1)
asm {};
else
asm {};
is mostly same as:
if (1) { asm {} }
;
else { asm {} }
;
and the 'else' part is stray.
Comment #2 by temtaime — 2013-08-13T10:51:48Z
Why asm statement doesn't follow common rules?
Comment #3 by maxim — 2013-08-13T11:05:42Z
(In reply to comment #2)
> Why asm statement doesn't follow common rules?
One reason is because although AsmStatement is formally a statement, it is actually close to a BlockStatement (AsmInstruction is close to regular statement) and BlockStatements don't have ";" after them (like aggregate type declarations and enum declarations).