According to https://nim-lang.org/docs/manual.html#type-relations-type-equality, name equivalence is used for objects, enumerations, distinct and generic types.
If name equivalence here means that two types are equal if and only if they have the same name, we can infer that
type A = object
type B = object
echo A is B #false
echo B is A #false
However, it cannot explain
type C = object
type D = C
#`C` and `D` also have different names.
echo C is D #true
echo D is C #true
I've searched in the page but couldn't find further explanations about name equivalence. Yeah, as xigoi said, if you just add the distinct label to D then it will return false.
Here is a code example:
type
C = object
D = distinct C
echo C is D # false
Then, I think it can be expressed with following rules:
Type T is equal to type S if:
Yes or like so:
Types T is equal to type S if T and S are both nominal types and refer to the same declaration or if both are structural types and their structures are equal.