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.
Comment #2 by k.hara.pg — 2012-11-13T04:20:53Z
Comment #3 by k.hara.pg — 2012-11-13T04:40:46Z
(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
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/d3595e31c087ca44e2f55d3267318ba8e176078e fix Issue 9004 - Wrong line number for undefined identifier error https://github.com/D-Programming-Language/dmd/commit/39a7788e5463c8b88b3ccc897795fd3978036137 Merge pull request #1283 from 9rnsr/fix9004 Issue 9004 - Wrong line number for undefined identifier error