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

Error: type mismatch: got <typedesc[A]>, but expected one of: A = proc (){.closure.} #23587

Open
haoyu234 opened this issue May 9, 2024 · 0 comments

Comments

@haoyu234
Copy link
Contributor

haoyu234 commented May 9, 2024

Description

https://play.nim-lang.org/#pasty=cVWRkhXTOfpv

Compiles normally on 'play.nim-lang.org' without uncommenting.
Compiling locally will report an error, just like the title says.

import std/tables

# After uncommenting and compiling on 'play.nim-lang.org', an error will be reported (killed by system)
# import std/asyncnet
# import std/asyncdispatch

type
  A = proc ()

proc main =
  let repo = initTable[uint32, A]()

  let c1 = repo.getOrDefault(uint32(1), nil)
  echo "c1.isNil: ", c1.isNil

  let c2 = repo.getOrDefault(uint32(1), A(nil))
  echo "c2.isNil: ", c2.isNil

main()

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2024-05-05
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 1ef4d04
active boot switches: -d:release

Current Output

/root/repos/spaces2/a.nim(13, 16) template/generic instantiation of `getOrDefault` from here
/root/.choosenim/toolchains/nim-#devel/lib/pure/collections/tables.nim(437, 19) Error: type mismatch: got <typedesc[A]>
but expected one of:
A = proc (){.closure.}

Expected Output

no error

Possible Solution

No response

Additional Information

No response

@haoyu234 haoyu234 changed the title Error: type mismatch: got <typedesc[A]>, but expected one of: A = proc (b: B){.closure.} Error: type mismatch: got <typedesc[A]>, but expected one of: A = proc (){.closure.} May 9, 2024
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