diff --git a/compiler/magicsys.nim b/compiler/magicsys.nim index 57b6a001ef..02f115714b 100644 --- a/compiler/magicsys.nim +++ b/compiler/magicsys.nim @@ -11,7 +11,7 @@ import ast, astalgo, msgs, platform, idents, - modulegraphs, lineinfos + modulegraphs, lineinfos, types export createMagic @@ -134,7 +134,7 @@ proc getNimScriptSymbol*(g: ModuleGraph; name: string): PSym = proc resetNimScriptSymbols*(g: ModuleGraph) = g.exposed = initStrTable() proc getMagicEqSymForType*(g: ModuleGraph; t: PType; info: TLineInfo): PSym = - case t.kind + case t.skipTypes(abstractRange).kind of tyInt, tyInt8, tyInt16, tyInt32, tyInt64, tyUInt, tyUInt8, tyUInt16, tyUInt32, tyUInt64: result = getSysMagic(g, info, "==", mEqI) diff --git a/tests/arc/tcaseobj.nim b/tests/arc/tcaseobj.nim index 0b085b6cc1..e320b8a4e3 100644 --- a/tests/arc/tcaseobj.nim +++ b/tests/arc/tcaseobj.nim @@ -365,3 +365,28 @@ proc do2(x: int, e: ItemExt): seq[(string, ItemExt)] = do1(x).map(proc(v: (string, Item)): auto = (v[0], ItemExt(a: v[1], b: e.b))) doAssert $do2(0, ItemExt(a: Item(kind: 1, c: "second"), b: "third")) == """@[("zero", (a: (kind: 1, c: "first"), b: "third"))]""" + +block: + type RangeCrash = object + case x: range[0..7] + of 0..2: + a: string + else: + b: string + + var rangeCrash = RangeCrash() + {.cast(uncheckedAssign).}: + rangeCrash.x = 5 + +block: + type Discrim = distinct uint8 + type DistinctCrash = object + case x: Discrim + of Discrim(0)..Discrim(2): + a: string + else: + b: string + + var distinctCrash = DistinctCrash() + {.cast(uncheckedAssign).}: + distinctCrash.x = Discrim(5)