mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-16 08:04:20 +00:00
fix #21251
(cherry picked from commit 76a98fee65)
This commit is contained in:
@@ -2930,6 +2930,8 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType
|
||||
else:
|
||||
{checkUndeclared, checkModule, checkAmbiguity, checkPureEnumFields}
|
||||
s = qualifiedLookUp(c, n, checks)
|
||||
if s == nil:
|
||||
return
|
||||
if c.matchedConcept == nil: semCaptureSym(s, c.p.owner)
|
||||
case s.kind
|
||||
of skProc, skFunc, skMethod, skConverter, skIterator:
|
||||
|
||||
@@ -71,9 +71,8 @@ template initImpl(result: typed, initialSize: int) =
|
||||
newSeq(result.data, correctSize)
|
||||
|
||||
template checkIfInitialized(deq: typed) =
|
||||
when compiles(defaultInitialSize):
|
||||
if deq.mask == 0:
|
||||
initImpl(deq, defaultInitialSize)
|
||||
if deq.mask == 0:
|
||||
initImpl(deq, defaultInitialSize)
|
||||
|
||||
proc initDeque*[T](initialSize: int = defaultInitialSize): Deque[T] =
|
||||
## Creates a new empty deque.
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
include hashcommon
|
||||
|
||||
const
|
||||
defaultInitialSize* = 32
|
||||
|
||||
template rawGetDeepImpl() {.dirty.} = # Search algo for unconditional add
|
||||
genHashImpl(key, hc)
|
||||
var h: Hash = hc and maxHash(t)
|
||||
@@ -31,9 +34,8 @@ proc rawInsert[X, A, B](t: var X, data: var KeyValuePairSeq[A, B],
|
||||
rawInsertImpl()
|
||||
|
||||
template checkIfInitialized() =
|
||||
when compiles(defaultInitialSize):
|
||||
if t.dataLen == 0:
|
||||
initImpl(t, defaultInitialSize)
|
||||
if t.dataLen == 0:
|
||||
initImpl(t, defaultInitialSize)
|
||||
|
||||
template addImpl(enlarge) {.dirty.} =
|
||||
checkIfInitialized()
|
||||
|
||||
@@ -217,8 +217,6 @@ type
|
||||
## For creating a new empty TableRef, use `newTable proc
|
||||
## <#newTable>`_.
|
||||
|
||||
const
|
||||
defaultInitialSize* = 32
|
||||
|
||||
# ------------------------------ helpers ---------------------------------
|
||||
|
||||
|
||||
6
tests/stdlib/t21251.nim
Normal file
6
tests/stdlib/t21251.nim
Normal file
@@ -0,0 +1,6 @@
|
||||
import std / [tables, sets, sharedtables]
|
||||
|
||||
var shared: SharedTable[int, int]
|
||||
shared.init
|
||||
|
||||
shared[1] = 1
|
||||
Reference in New Issue
Block a user