mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-29 10:01:39 +00:00
Fix scanTuple undeclared identifier 'scanf' (#24759)
Without this fix, trying to use `scanTuple` in a generic proc imported
from a different module fails to compile (`undeclared identifier:
'scanf'`):
```nim
# module.nim
import std/strscans
proc scan*[T](s: string): (bool, string) =
s.scanTuple("$+")
```
```nim
# main.nim
import ./module
echo scan[int]("foo")
```
Workaround is to `export scanf` in `module.nim` or `import std/strscans`
in `main.nim`.
This commit is contained in:
4
tests/stdlib/mstrscans_undecl_scanf.nim
Normal file
4
tests/stdlib/mstrscans_undecl_scanf.nim
Normal file
@@ -0,0 +1,4 @@
|
||||
import std/strscans
|
||||
|
||||
proc scan*[T](s: string): (bool, string) =
|
||||
s.scanTuple("$+")
|
||||
3
tests/stdlib/tstrscans_undecl_scanf.nim
Normal file
3
tests/stdlib/tstrscans_undecl_scanf.nim
Normal file
@@ -0,0 +1,3 @@
|
||||
import std/assertions
|
||||
import ./mstrscans_undecl_scanf
|
||||
doAssert scan[int]("foo") == (true, "foo")
|
||||
Reference in New Issue
Block a user