Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nimsuggest shows an error with anyIt from sequtils #118

Open
ghost opened this issue Oct 20, 2020 · 1 comment
Open

nimsuggest shows an error with anyIt from sequtils #118

ghost opened this issue Oct 20, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 20, 2020

template anyIt*(s, pred: untyped): bool =
  var result = false
  for it {.inject.} in items(s):
    if pred:
      result = true
      break
  result

let path = "hello.backup"
if ["backup", "orig", "old2", "old", ".1"].anyIt(it in path): echo "wow"
❰dian❙~/Projects/nim-snippets(git:master)❱✔≻ nimsuggest --stdin a.nim
> chk a.nim
chk     skUnknown               Hint    ???     0       -1      "a [Processing]"        0
chk     skUnknown               Error   /home/dian/Projects/nim-snippets/a.nim  10      52      "type mismatch: got <string, string>\x0Abut expected one of: \x0Aproc contains[T](a: openArray[T]; item: T): bool\x0A  first type mismatch at position: 2\x0A  required type for item: T\x0A  but expression \'it\' is of type: string\x0A2 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them\x0A\x0Aexpression: contains(path, it)"  0
chk     skUnknown               Error   /home/dian/Projects/nim-snippets/a.nim  10      52      "expression \'\' has no type (or is ambiguous)" 0

> 
@saem
Copy link

saem commented Dec 19, 2020

I don't think this is a bug, you're missing an import strutils at the top, as in is sugar for contains, and the particular implementation you're looking for is defined within the strutils module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant