* fixes #19967 * use case * add testcase * fix typos * explictly specify other branches Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
This commit is contained in:
parent
32e4b33632
commit
e8556b45f5
2 changed files with 41 additions and 1 deletions
|
|
@ -87,7 +87,20 @@ proc specializeResetT(p: BProc, accessor: Rope, typ: PType) =
|
||||||
lineCg(p, cpsStmts, "$1 = 0;$n", [accessor])
|
lineCg(p, cpsStmts, "$1 = 0;$n", [accessor])
|
||||||
of tyCstring, tyPointer, tyPtr, tyVar, tyLent:
|
of tyCstring, tyPointer, tyPtr, tyVar, tyLent:
|
||||||
lineCg(p, cpsStmts, "$1 = NIM_NIL;$n", [accessor])
|
lineCg(p, cpsStmts, "$1 = NIM_NIL;$n", [accessor])
|
||||||
else:
|
of tySet:
|
||||||
|
case mapSetType(p.config, typ)
|
||||||
|
of ctArray:
|
||||||
|
lineCg(p, cpsStmts, "#nimZeroMem($1, sizeof($2));$n",
|
||||||
|
[accessor, getTypeDesc(p.module, typ)])
|
||||||
|
of ctInt8, ctInt16, ctInt32, ctInt64:
|
||||||
|
lineCg(p, cpsStmts, "$1 = 0;$n", [accessor])
|
||||||
|
else:
|
||||||
|
doAssert false, "unexpected set type kind"
|
||||||
|
of {tyNone, tyEmpty, tyNil, tyUntyped, tyTyped, tyGenericInvocation,
|
||||||
|
tyGenericParam, tyOrdinal, tyRange, tyOpenArray, tyForward, tyVarargs,
|
||||||
|
tyUncheckedArray, tyProxy, tyBuiltInTypeClass, tyUserTypeClass,
|
||||||
|
tyUserTypeClassInst, tyCompositeTypeClass, tyAnd, tyOr, tyNot,
|
||||||
|
tyAnything, tyStatic, tyFromExpr, tyConcept, tyVoid, tyIterable}:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc specializeReset(p: BProc, a: TLoc) =
|
proc specializeReset(p: BProc, a: TLoc) =
|
||||||
|
|
|
||||||
|
|
@ -74,3 +74,30 @@ template main =
|
||||||
|
|
||||||
static: main()
|
static: main()
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
# bug #19967
|
||||||
|
block:
|
||||||
|
type
|
||||||
|
X = object
|
||||||
|
a: string
|
||||||
|
b: set[char]
|
||||||
|
|
||||||
|
var y = X(b: {'a'})
|
||||||
|
|
||||||
|
reset(y)
|
||||||
|
|
||||||
|
doAssert y.b == {}
|
||||||
|
|
||||||
|
block:
|
||||||
|
type
|
||||||
|
Color = enum
|
||||||
|
Red, Blue, Yellow
|
||||||
|
X = object
|
||||||
|
a: string
|
||||||
|
b: set[Color]
|
||||||
|
|
||||||
|
var y = X(b: {Red, Blue})
|
||||||
|
|
||||||
|
reset(y)
|
||||||
|
doAssert y.b == {}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue