-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
import sets
type
parent = object
hash: HashSet[string]
proc getParent(): parent =
result.hash.init()
let a = getParent()
a.hash.incl("Hello")Here a is read-only so Nim should tell you that. Instead you see the following error which is hard to figure out.
ctest.nim(11, 7) Error: type mismatch: got <HashSet[system.string], string>
but expected one of:
proc incl[T](x: var set[T]; y: T)
first type mismatch at position: 1
required type: var set[T]
but expression 'a.hash' is of type: HashSet[system.string]
template incl[T](s: var set[T]; flags: set[T])
first type mismatch at position: 1
required type: var set[T]
but expression 'a.hash' is of type: HashSet[system.string]
proc incl[A](s: var HashSet[A]; key: A)
first type mismatch at position: 1
required type: var HashSet[incl.A]
but expression 'a.hash' is of type: HashSet[system.string]
proc incl[A](s: var HashSet[A]; other: OrderedSet[A])
first type mismatch at position: 1
required type: var HashSet[incl.A]
but expression 'a.hash' is of type: HashSet[system.string]
proc incl[A](s: var OrderedSet[A]; key: A)
first type mismatch at position: 1
required type: var OrderedSet[incl.A]
but expression 'a.hash' is of type: HashSet[system.string]
proc incl[A](s: var HashSet[A]; other: HashSet[A])
first type mismatch at position: 1
required type: var HashSet[incl.A]
but expression 'a.hash' is of type: HashSet[system.string]
expression: incl(a.hash, "Hello")