November 19, 2023 [Issue 24249] New: compiler error in templated class in templated interface implementation class is masked if templated class imports self and interface is instantiated from third module | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24249 Issue ID: 24249 Summary: compiler error in templated class in templated interface implementation class is masked if templated class imports self and interface is instantiated from third module Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: d.bugs@webfreak.org reproduction: ``` // console.d module console; final class PosixEventDriverConsole(T) { import posixdriver; void compilerError(int x) { foo(x.nonExistant); } } ``` ``` // posixdriver.d module posixdriver; import console; interface EventDriver { bool dispose(); } final class PosixEventDriver(Loop) : EventDriver { private { alias ConsoleDriver = PosixEventDriverConsole!Loop; ConsoleDriver m_console; } override bool dispose() { return false; } } ``` ``` // app.d import posixdriver; alias EpollEventDriver = PosixEventDriver!int; ``` compiling with `dmd app.d console.d posixdriver.d` errors with: ``` posixdriver.d(9): Error: class `posixdriver.PosixEventDriver!int.PosixEventDriver` interface function `bool dispose()` is not implemented app.d(3): Error: template instance `posixdriver.PosixEventDriver!int` error instantiating posixdriver.d(11): Error: template instance `console.PosixEventDriverConsole!int` error instantiating app.d(3): instantiated from here: `PosixEventDriver!int` ``` when you remove the `import posixdriver;` inside console.d the error message changes to the expected one: ``` console.d(8): Error: undefined identifier `foo` posixdriver.d(11): Error: template instance `console.PosixEventDriverConsole!int` error instantiating app.d(3): instantiated from here: `PosixEventDriver!int` ``` In big code bases this makes the coding error almost impossible to find since the error indicates a vastly different location. -- |
Copyright © 1999-2021 by the D Language Foundation