Nim
Nim copied to clipboard
Callbacks in methods cause internal error getTypeDescAux(tyBuiltInTypeClass)
Attempting to call a method on a "subclass" with a callback throws an internal error.
Example
type
Entity = ref object of RootObj
SubEntity = ref object of Entity
method foo(this: Entity, callback: proc = nil) {.base.} =
if callback != nil:
callback()
method foo(this: SubEntity, callback: proc = nil) =
procCall Entity(this).foo(proc =
echo "in callback"
)
let sub = SubEntity()
sub.foo()
Current Output
From the playground:
usercode/in.nim(5, 1) Warning: generic methods are deprecated [Deprecated]
/usercode/in.nim(9, 1) Warning: generic methods are deprecated [Deprecated]
/usercode/in.nim(9, 8) Warning: use {.base.} for base methods; baseless methods are deprecated [UseBase]
Error: internal error: getTypeDescAux(tyBuiltInTypeClass)
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp c <file>', see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for details
Expected Output
in callback