diff options
author | Bung <crc32@qq.com> | 2022-12-22 13:16:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-22 06:16:25 +0100 |
commit | c5a72ebddd88b6d3a2712230d36367f180faa7da (patch) | |
tree | 4ac82b411e88aea745ef2ebf8c23d44545b93be8 | |
parent | 613829f7a4da5506269fadb3acc78d64ee0cbddf (diff) | |
download | Nim-c5a72ebddd88b6d3a2712230d36367f180faa7da.tar.gz |
fix #16541 (#21148)
-rw-r--r-- | compiler/sigmatch.nim | 2 | ||||
-rw-r--r-- | tests/misc/t16541.nim | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 51728b103..61a4395f3 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -2150,6 +2150,8 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType, elif arg.sym.kind in {skMacro, skTemplate}: return nil else: + if arg.sym.ast == nil: + return nil let inferred = c.semGenerateInstance(c, arg.sym, m.bindings, arg.info) result = newSymNode(inferred, arg.info) if r == isInferredConvertible: diff --git a/tests/misc/t16541.nim b/tests/misc/t16541.nim new file mode 100644 index 000000000..452327e8f --- /dev/null +++ b/tests/misc/t16541.nim @@ -0,0 +1,12 @@ +discard """ + action: "reject" + +""" + +import strutils, sugar, nre + +proc my_replace*(s: string, r: Regex, by: string | (proc (match: string): string)): string = + nre.replace(s, r, by) + +discard my_replace("abcde", re"[bcd]", match => match.to_upper) == "aBCDe" +discard my_replace("abcde", re"[bcd]", (match: string) => match.to_upper) == "aBCDe" |