Skip to content

Commit

Permalink
fix #16541 (#21148)
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 authored Dec 22, 2022
1 parent 613829f commit c5a72eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions tests/misc/t16541.nim
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit c5a72eb

Please sign in to comment.