From 8ef554501fb9578a1af50e42050a557b9c8b8286 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 7 Aug 2017 20:59:32 +0700 Subject: [PATCH] Add nil check to tilde --- godot/nim/godotnim.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/godot/nim/godotnim.nim b/godot/nim/godotnim.nim index b9eafa3..f8893d5 100644 --- a/godot/nim/godotnim.nim +++ b/godot/nim/godotnim.nim @@ -279,7 +279,8 @@ proc `as`*[T: NimGodotObject](obj: NimGodotObject, t: typedesc[T]): T = T.name & "\n" & getStackTrace()) result = nil -proc `~`*[T: NimGodotObject](obj: NimGodotObject, t: typedesc[T]): bool = +proc `~`*[T: NimGodotObject](obj: NimGodotObject, + t: typedesc[T]): bool {.inline.} = ## Godot-specific inheritance check. You must use this over Nim's standard ## ``of`` operator, because Nim does not know which object your script is ## attached to in runtime. For example, if you create a @@ -288,7 +289,7 @@ proc `~`*[T: NimGodotObject](obj: NimGodotObject, t: typedesc[T]): bool = ## ``myBullet ~ MeshInstance`` will return ``true``. ## This is going to be changed to ``of`` in later versions, when Nim starts ## supporting overloading ``of`` operator. - obj of T or obj.linkedObject of T + not obj.isNil and (obj of T or obj.linkedObject of T) proc newRStrLit(s: string): NimNode {.compileTime.} = result = newNimNode(nnkRStrLit)