Skip to content

Instantly share code, notes, and snippets.

Created March 13, 2018 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5ca5421d6f2c3190edbed54f7d03b341 to your computer and use it in GitHub Desktop.
Save anonymous/5ca5421d6f2c3190edbed54f7d03b341 to your computer and use it in GitHub Desktop.
Snippet from snip
import sets
type
parent = object
hash: HashSet[string]
proc getParent(): parent =
result.hash.init()
let a = getParent()
a.hash.incl("Hello")
@genotrance
Copy link

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")

@genotrance
Copy link

let a is not writable but error message is confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment