Thread overview
[Issue 19232] ICE when overriding templated method
Sep 07, 2018
Simen Kjaeraas
Sep 07, 2018
Michael Galuza
Sep 09, 2018
RazvanN
Sep 09, 2018
RazvanN
Mar 02, 2019
Basile-z
Mar 02, 2019
Basile-z
Mar 21, 2020
Basile-z
September 07, 2018
https://issues.dlang.org/show_bug.cgi?id=19232

Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic, ice
                 CC|                            |simen.kjaras@gmail.com
            Summary|Compiler bug when override  |ICE when overriding
                   |function with template this |templated method

--- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
Further reduced:

abstract class Bar {
        void get(A)() { }
}

class Foo : Bar {
        override void get() { }
}

unittest {
        Bar foo = new Foo();
        foo.get();
}

Now, this shouldn't actually work, since template methods are implicitly final (and can't be made virtual in any way). If Bar.get is made into a final, non-templated method, you get the message `Foo.get cannot override final function Bar.get`. The correct error message in this case would be `Foo.get cannot override template function Bar.get`.

(note that the stack trace on the ICE varies wildly with changes in the code above - adding or removing template-ness of Foo and Bar, as well as removing the Unknown class, completely changes it. This could thus be an issue in more than one source code location)

--
September 07, 2018
https://issues.dlang.org/show_bug.cgi?id=19232

--- Comment #2 from Michael Galuza <riddlermichael@gmail.com> ---
(In reply to Simen Kjaeraas from comment #1)
> Further reduced:
> 
> abstract class Bar {
> 	void get(A)() { }
> }
> 
> class Foo : Bar {
> 	override void get() { }
> }
> 
> unittest {
> 	Bar foo = new Foo();
> 	foo.get();
> }
> 
> Now, this shouldn't actually work, since template methods are implicitly final (and can't be made virtual in any way). If Bar.get is made into a final, non-templated method, you get the message `Foo.get cannot override final function Bar.get`. The correct error message in this case would be `Foo.get cannot override template function Bar.get`.
> 
> (note that the stack trace on the ICE varies wildly with changes in the code above - adding or removing template-ness of Foo and Bar, as well as removing the Unknown class, completely changes it. This could thus be an issue in more than one source code location)

Thank you for detailed explanation! Anyway, it's ICE)

--
September 09, 2018
https://issues.dlang.org/show_bug.cgi?id=19232

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to Simen Kjaeraas from comment #1)
> Further reduced:
> 
> abstract class Bar {
> 	void get(A)() { }
> }
> 
> class Foo : Bar {
> 	override void get() { }
> }
> 
> unittest {
> 	Bar foo = new Foo();
> 	foo.get();
> }
> 
> Now, this shouldn't actually work, since template methods are implicitly final (and can't be made virtual in any way). If Bar.get is made into a final, non-templated method, you get the message `Foo.get cannot override final function Bar.get`. The correct error message in this case would be `Foo.get cannot override template function Bar.get`.
> 
> (note that the stack trace on the ICE varies wildly with changes in the code above - adding or removing template-ness of Foo and Bar, as well as removing the Unknown class, completely changes it. This could thus be an issue in more than one source code location)

PR: https://github.com/dlang/dmd/pull/8665 fixes this. With that patch the error message is:

issue.d(8): Error: function void issue.Foo.get() does not override any
function, did you mean to override template issue.Bar.get(A)()?
issue.d(8):        Functions are the only declarations that may be overriden

I suggest closing this as fixed.

--
September 09, 2018
https://issues.dlang.org/show_bug.cgi?id=19232

--- Comment #4 from RazvanN <razvan.nitu1305@gmail.com> ---
However, the following code compiles successfully :

abstract class Bar {
        void get(A)() { }
}

class Foo : Bar {
        override void get(A)() { }
}

unittest {
        Bar foo = new Foo();
        foo.get!(int)();
}

compiles successfully and the method in the Bar is called.

--
March 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19232

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice                         |
                 CC|                            |b2.temp@gmx.com
           Hardware|x86                         |All
                 OS|Windows                     |All

--
March 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19232

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #5 from Basile-z <b2.temp@gmx.com> ---


*** This issue has been marked as a duplicate of issue 11455 ***

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=19232

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--