[Issue 19232] ICE when overriding templated method

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 9 11:19:17 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19232

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

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

--- Comment #3 from RazvanN <razvan.nitu1305 at 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.

--


More information about the Digitalmars-d-bugs mailing list