Files
Nim/tests/stdlib/t8925.nim
Jake Leahy 9e1b199e78 Minor std/strscans improvements (#24566)
#### Removes UnInit warnings when using `scanTuple`

e.g. this would emit a warning
```nim
import std/strscans

proc main() =
  let (ok, number) = "123".scanTuple()
```

![image](https://github.com/user-attachments/assets/68170ac6-402d-48b0-b8b6-69e71f4b70ae)

#### Error for wrong type now points to the passed in variable

```nim
import std/strscans

var str: string
discard "123".scanf("$i", str)
```

it gave this warning before

![image](https://github.com/user-attachments/assets/096e56d2-0eb5-4c67-9725-25caa97afebd)
now it returns

![image](https://github.com/user-attachments/assets/736a4292-2f56-4cf3-a27a-677045377171)

(cherry picked from commit 5b9ff963c5)
2025-01-15 10:21:00 +01:00

17 lines
258 B
Nim

discard """
errormsg: "type mismatch between pattern '$$i' (position: 1) and HourRange var 'hour'"
file: "t8925.nim"
"""
import strscans
type
HourRange = range[0..23]
var
hour: HourRange
timeStr: string
if scanf(timeStr, "$i", hour):
discard