Bug 24249 – compiler error in templated class in templated interface implementation class is masked if templated class imports self and interface is instantiated from third module

Status
NEW
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-11-19T14:46:43Z
Last change time
2024-12-13T19:31:51Z
Assigned to
No Owner
Creator
Jan Jurzitza
Moved to GitHub: dmd#20360 →

Comments

Comment #0 by d.bugs — 2023-11-19T14:46:43Z
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.
Comment #1 by robert.schadek — 2024-12-13T19:31:51Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20360 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB