Bug 9004 – Wrong line number for undefined identifier error
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-11-12T05:12:00Z
Last change time
2012-11-13T14:37:24Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-11-12T05:12:35Z
This is probably wrong code:
struct Foo(_T) {
alias _T T;
}
void bar(FooT)(FooT foo, FooT.T x) {
}
void main() {
Foo!int foo;
bar(foo, 1); // line 8
}
DMD 2.061alpha gives:
test.d(8): Error: undefined identifier FooT.T
test.d(8): Error: template test.bar does not match any function template declaration
test.d(8): Error: template test.bar(FooT) cannot deduce template function from argument types !()(Foo!(int),int)
Note the line number where the "undefined identifier FooT.T" error is.
Comment #1 by andrej.mitrovich — 2012-11-12T06:24:11Z
I don't think this is wrong code though.. You can declare `FooT.T x;` inside the function body, I don't see why it shouldn't be allowed in the function header.
(In reply to comment #1)
> I don't think this is wrong code though.. You can declare `FooT.T x;` inside
> the function body, I don't see why it shouldn't be allowed in the function
> header.
If a part of function parameter type is a template parameter, as like `FooT.T`, it doesn't work in current IFTI mechanism.
D has a proper module system, so its working would be worth. But it is yet an enhancement request.
Comment #4 by github-bugzilla — 2012-11-13T14:04:55Z