Add hasClosure to std/typetraits (#17501)

* fix nim js cmp fails at CT

* Add `hasClosure` to `std/effecttraits`

* type

* Update changelog.md

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update lib/std/effecttraits.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
flywind 2021-03-29 20:22:29 +08:00 • committed by GitHub
commit 81e54c1d30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 109 additions and 0 deletions

View file

@ -263,3 +263,14 @@ since (1, 1):
type T2 = T
genericParamsImpl(T2)
proc hasClosureImpl(n: NimNode): bool = discard "see compiler/vmops.nim"
proc hasClosure*(fn: NimNode): bool {.since: (1, 5, 1).} =
## Return true if the func/proc/etc `fn` has `closure`.
## `fn` has to be a resolved symbol of kind `nnkSym`. This
## implies that the macro that calls this proc should accept `typed`
## arguments and not `untyped` arguments.
expectKind fn, nnkSym
result = hasClosureImpl(fn)