Does Nim have equivalent of Java instanceof/C++ dynamic_cast<T>!=nullptr?
For example:
# ref type with inheritance hierarchy.
type
A = ref object {.inheritable.}
B = ref object of A
C = ref object of A
var c: C
new(c)
let as_root: A = c
assert instanceOf(as_root, C) == true
assert instanceOf(as_root, B) == false
I could cast getTypeInfo to PNimType and do checking myself, but this doesn't sound like a correct solution.
Looks like what you're looking for is the of keyword:
var exc: ref RootObj = newException(ValueError, "Test")
assert(exc of ValueError)
assert(not (exc of OSError))