D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2010 - Template tuples don't work in string mixins
Summary: Template tuples don't work in string mixins
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks: 340
  Show dependency treegraph
 
Reported: 2008-04-18 18:02 UTC by Bartosz Milewski
Modified: 2015-06-09 01:14 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bartosz Milewski 2008-04-18 18:02:34 UTC
A variable-argument function works at runtime, but doesn't compile as a mixin:

mixin (declareAllFeatures ("a", "b", "c"));

string declareAllFeatures (T...)(T features)
{
	string [] arr = [];
	foreach (f; features)
	{
		arr ~= f;
	}
	return declareAllFeaturesArr (arr);
}

string declareAllFeaturesArr (string [] allFeatures)
{
	return "int x;";
}
Comment 1 Bartosz Milewski 2008-04-18 18:08:10 UTC
The order of declarations seems to matter, so here's the modified example and the error message:

string declareAllFeaturesArr (string [] allFeatures)
{
    return "int x;";
}

string declareAllFeatures (T...)(T features)
{
    string [] arr = [];
    foreach (f; features)
    {
            arr ~= f;
    }
    return declareAllFeaturesArr (arr);
}

mixin (declareAllFeatures ("a", "b", "c"));

Error: cannot evaluate declareAllFeatures(&"a",&"b",&"c") at compile time
Comment 2 Don 2009-09-23 05:25:00 UTC
This was fixed before 2.022.