mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
@@ -702,6 +702,12 @@ template inst(field, t) =
|
||||
proc isTrival(s: PSym): bool {.inline.} =
|
||||
s == nil or (s.ast != nil and s.ast[bodyPos].len == 0)
|
||||
|
||||
|
||||
proc isEmptyContainer(g: ModuleGraph, t: PType): bool =
|
||||
(t.kind == tyArray and lengthOrd(g.config, t[0]) == 0) or
|
||||
(t.kind == tySequence and t[0].kind == tyError)
|
||||
|
||||
|
||||
proc createTypeBoundOps(g: ModuleGraph; c: PContext; orig: PType; info: TLineInfo) =
|
||||
## In the semantic pass this is called in strategic places
|
||||
## to ensure we lift assignment, destructors and moves properly.
|
||||
@@ -710,6 +716,7 @@ proc createTypeBoundOps(g: ModuleGraph; c: PContext; orig: PType; info: TLineInf
|
||||
incl orig.flags, tfCheckedForDestructor
|
||||
|
||||
let skipped = orig.skipTypes({tyGenericInst, tyAlias, tySink})
|
||||
if isEmptyContainer(skipped): return
|
||||
|
||||
let h = sighashes.hashType(skipped, {CoType, CoConsiderOwned, CoDistinct})
|
||||
var canon = g.canonTypes.getOrDefault(h)
|
||||
|
||||
@@ -16,3 +16,10 @@ proc test() =
|
||||
doAssert cast[int](sq1[0].unsafeAddr) != 0
|
||||
|
||||
test()
|
||||
|
||||
|
||||
#############################################
|
||||
### bug 12820
|
||||
import tables
|
||||
var t = initTable[string, seq[ptr int]]()
|
||||
discard t.hasKeyOrPut("f1", @[])
|
||||
|
||||
Reference in New Issue
Block a user