D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4321 - Passing local parameter to non-global template fails.
Summary: Passing local parameter to non-global template fails.
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: Walter Bright
URL:
Keywords:
Depends on: 3052
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-15 06:50 UTC by ibrahim YANIKLAR
Modified: 2011-11-27 12:35 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 ibrahim YANIKLAR 2010-06-15 06:50:17 UTC
class C
{
	void f(int i)()
	{
	}
	
	void g()
	{
		foreach (i; Range!(1,10))
			f!(i)();
	}
}


Error: template instance cannot use local 'i' as parameter to non-global template f(uint i)

I think it should work.
Comment 1 ibrahim YANIKLAR 2010-11-27 10:37:15 UTC
The code below works:

class C
{
    void f(int i)()
    {
    }

    void g()
    {
        foreach (i; Range!(1,10))
            h!(i)(this);
    }
}

void h(int i)(C c)
{
    c.f!(i)();
}

Probably that is only a compiler limitation and can be fixed (or removed) without much effort.
Comment 2 Trass3r 2011-11-27 12:35:53 UTC
Works now.