Bug 23576 – Better Error Message When Forgetting To Pass A Template Parameter

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-12-23T18:55:21Z
Last change time
2024-12-13T19:26:29Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Jack Stouffer
Moved to GitHub: dmd#18144 →

Comments

Comment #0 by jack — 2022-12-23T18:55:21Z
Current Behavior Consider the following program import std; void test1(uint id, uint __) { int x = 0; } void test2(C)(uint id) { int x = 0; } void main() { uint a = 0; test1(a); test2(a); } For test1, DMD gives a good error message: onlineapp.d(16): Error: function `onlineapp.test1(uint id, uint __)` is not callable using argument types `(uint)` onlineapp.d(16): missing argument for parameter #2: `uint __` This tells the user exactly what's wrong. Great! On the other hand, the test2 error message isn't as helpful onlineapp.d(17): Error: none of the overloads of template `onlineapp.test2` are callable using argument types `!()(uint)` onlineapp.d(8): Candidate is: `test2(C)(uint id)` Expected Behavior: The error message should be something like onlineapp.d(16): Error: function `onlineapp.test2(C)(uint id)` is not callable using argument types `(uint)` onlineapp.d(16): missing argument for template parameter #1: `C`
Comment #1 by salihdb — 2022-12-24T00:00:16Z
You are right, previous version error: Issue23576.d(22): Error: template `source.test3` cannot deduce function from argument types `!()(byte)`, candidates are: Issue23576.d(8): `source.test3(E)(int d)` Same codes: void test2(C)(C d) {  byte x = 42;  assert(d == x);  assert(is(typeof(x) : C)); } template test3(E) {  void test3(E d) {    byte x = 42; assert(d == x);    assert(is(typeof(x) : E)); } } void main() {    byte a = 42;    test2(a);    test3(a); }
Comment #2 by robert.schadek — 2024-12-13T19:26:29Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18144 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB