diff --git a/lib/pure/strscans.nim b/lib/pure/strscans.nim index 45ba9a469c..cbb1124420 100644 --- a/lib/pure/strscans.nim +++ b/lib/pure/strscans.nim @@ -512,7 +512,7 @@ macro scanTuple*(input: untyped; pattern: static[string]; matcherTypes: varargs[ inc userMatches else: discard inc p - result.add nnkTupleConstr.newTree(newCall(ident("scanf"), input, newStrLitNode(pattern))) + result.add nnkTupleConstr.newTree(newCall(bindSym("scanf"), input, newStrLitNode(pattern))) for arg in arguments: result[^1][0].add arg result[^1].add arg diff --git a/tests/stdlib/mstrscans_undecl_scanf.nim b/tests/stdlib/mstrscans_undecl_scanf.nim new file mode 100644 index 0000000000..24ce23ee6d --- /dev/null +++ b/tests/stdlib/mstrscans_undecl_scanf.nim @@ -0,0 +1,4 @@ +import std/strscans + +proc scan*[T](s: string): (bool, string) = + s.scanTuple("$+") diff --git a/tests/stdlib/tstrscans_undecl_scanf.nim b/tests/stdlib/tstrscans_undecl_scanf.nim new file mode 100644 index 0000000000..a2b6e8386f --- /dev/null +++ b/tests/stdlib/tstrscans_undecl_scanf.nim @@ -0,0 +1,3 @@ +import std/assertions +import ./mstrscans_undecl_scanf +doAssert scan[int]("foo") == (true, "foo")