D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2288 - Cannot mixin a case or default statement
Summary: Cannot mixin a case or default statement
Status: RESOLVED DUPLICATE of issue 1534
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2008-08-17 04:45 UTC by Matti Niemenmaa
Modified: 2014-03-01 00:36 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Matti Niemenmaa 2008-08-17 04:45:40 UTC
void main() {
	switch (0) {
		mixin ("case 0: break;");
		default: assert (0);
	}
}

The above code fails to compile with repeated "found 'EOF' instead of statement" errors on the line of the mixin, as does the following:

void main() {
	switch (0) {
		mixin ("default: break;");
	}
}

Were they not mixins, the code would compile and run fine.

Mixing in ordinary labelled statements works:

void main() {
	goto x;
	assert (0);
	mixin("x:;");
}

Workarounds:

Mixing in the entire switch statement:

void main() {
	mixin("switch (0) {"
		"case 0: break;"
		"default: assert (0);"
	"}");
}

Or just the block statement inside the switch:

void main() {
	switch (0) mixin("{"
		"case 0: break;"
		"default: assert (0);"
	"}");
}
Comment 1 Rainer Schuetze 2009-09-07 23:16:35 UTC

*** This issue has been marked as a duplicate of issue 1534 ***