You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def result is incorrect when using the for loop without explicit call of .items or .pairs.
import std/tables
let t =initTable[string, int]()
for key, value in t:
discard value
let r =0..2for value in r:
discard value
let s =@[1, 2, 3]
for value in s:
discard value
let str ="hello"for value in str:
discard value
Nim Version
Nim Compiler Version 2.2.1 [Windows: amd64]
Compiled at 2024-11-28
Copyright (c) 2006-2024 by Andreas Rumpf
active boot switches: -d:release
Current Output
for key, value in t:
^ <-- here
> def 4:19
def skIterator tables.pairs iterator (t: Table[pairs.A, pairs.B]): (A, B){.inline.} ...\nim\lib\pure\collections\tables.nim 680 9 "Iterates over any `(key, value)` pair in the table `t`.\x0A\x0ASee also:\x0A* `mpairs iterator<#mpairs.i,Table[A,B]>`_\x0A* `keys iterator<#keys.i,Table[A,B]>`_\x0A* `values iterator<#values.i,Table[A,B]>`_\x0A\x0A**Examples:**\x0A\x0A \x0A let a = {\x0A \'o\': [1, 5, 7, 9],\x0A \'e\': [2, 4, 6, 8]\x0A }.toTable\x0A\x0A for k, v in a.pairs:\x0A echo \"key: \", k\x0A echo \"value: \", v\x0A\x0A # key: e\x0A # value: [2, 4, 6, 8]\x0A # key: o\x0A # value: [1, 5, 7, 9]\x0A " 100
for value in r:
^ <-- here
> def 8:14
def skIterator iterators.items iterator (s: Slice[items.T]): T: Ordinal{.inline.} ...\nim\lib\system\iterators.nim 140 9 "Iterates over the slice `s`, yielding each value between `s.a` and `s.b`\x0A(inclusively)." 100
for value in s:
^ <-- here
> def 12:14
def skIterator iterators.items iterator (a: seq[T]): lent T{.inline, raises: <inferred> [].} ...\nim\lib\system\iterators.nim 247 9 "Iterates over each item of `a`." 100
for value in str:
^ <-- here
> def 16:14
def skIterator iterators.items iterator (a: string): char{.inline, noSideEffect, gcsafe, raises: <inferred> [].} ...\nim\lib\system\iterators.nim 265 9 "Iterates over each item of `a`."
Expected Output
for key, value in t:
^ <-- here
> def 4:19
def skLet main.t Table[system.string, system.int] ...\main.nim 3 4 ""
for value in r:
^ <-- here
> def 8:14
def skLet main.r HSlice[system.int, system.int] ...\main.nim 7 4 ""
for value in s:
^ <-- here
> def 12:14
def skLet main.s seq[int] ...\main.nim 11 4 ""
for value in str:
^ <-- here
> def 16:14
def skLet main.str string ...\main.nim 15 4 ""
Known Workarounds
No response
Additional Information
table and string works as expected in nimsuggest --v2 but not in v3, v4
for key, value in t:
^ <-- here
for value in str:
^ <-- here
The text was updated successfully, but these errors were encountered:
Description
def
result is incorrect when using the for loop without explicit call of.items
or.pairs
.Nim Version
Nim Compiler Version 2.2.1 [Windows: amd64]
Compiled at 2024-11-28
Copyright (c) 2006-2024 by Andreas Rumpf
active boot switches: -d:release
Current Output
Expected Output
Known Workarounds
No response
Additional Information
table
andstring
works as expected innimsuggest --v2
but not inv3
,v4
The text was updated successfully, but these errors were encountered: