diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-04-02 04:11:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-02 13:11:03 +0200 |
commit | 9abd383a2ae36e50ee23b78654e9d8154db46c84 (patch) | |
tree | 9003ce257986ab8c6cc21d03ed9fd7f67c8dab5b /lib/core | |
parent | 774e66f3d123520c44016ca23fd103538fc3c87d (diff) | |
download | Nim-9abd383a2ae36e50ee23b78654e9d8154db46c84.tar.gz |
new `genAst` as replacement for `quote do` (#17426)
* new `macros.genAst`: fixes all issues with `quote do` * add changelog entry * add workaround for https://github.com/nim-lang/Nim/issues/2465#issuecomment-511076669 * add test for #9607 * add kNoExposeLocalInjects option * add test case for nested application of genAst * genAst: automatically call newLit when needed * allow skipping `{}`: genAst: foo * add test that shows this fixes #11986 * add examples showing mixin; add examples showing passing types, macros, templates * move to std/genasts * improve docs
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 795909c6b..49c9a999c 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -539,6 +539,7 @@ proc parseStmt*(s: string): NimNode {.noSideEffect.} = proc getAst*(macroOrTemplate: untyped): NimNode {.magic: "ExpandToAst", noSideEffect.} ## Obtains the AST nodes returned from a macro or template invocation. + ## See also `genasts.genAst`. ## Example: ## ## .. code-block:: nim @@ -559,6 +560,8 @@ proc quote*(bl: typed, op = "``"): NimNode {.magic: "QuoteAst", noSideEffect.} = ## ## A custom operator interpolation needs accent quoted (``) whenever it resolves ## to a symbol. + ## + ## See also `genasts <genasts.html>`_ which avoids some issues with `quote`. runnableExamples: macro check(ex: untyped) = # this is a simplified version of the check macro from the @@ -1419,7 +1422,7 @@ proc expectIdent*(n: NimNode, name: string) {.since: (1,1).} = if not eqIdent(n, name): error("Expected identifier to be `" & name & "` here", n) -proc hasArgOfName*(params: NimNode; name: string): bool= +proc hasArgOfName*(params: NimNode; name: string): bool = ## Search `nnkFormalParams` for an argument. expectKind(params, nnkFormalParams) for i in 1..<params.len: |