Nim icon indicating copy to clipboard operation
Nim copied to clipboard

v2.0.3 ICE regression: call toSeq in a iterator in a closure

Open jangko opened this issue 6 months ago • 0 comments

Description

import
  std/[sequtils, tables]
  
type
  MemBackendRef = ref object
    rFil: Table[int,int]

iterator walkFil(be: MemBackendRef): int =
  for qid in be.rFil.keys.toSeq:
    yield qid

proc verifyFilters() =
  proc verifyImpl(be: MemBackendRef) =
    for fid in walkFil(be):
      echo fid

  let be = MemBackendRef()
  verifyImpl(be)

verifyFilters()

Nim Version

Nim Compiler Version 2.0.3 [Windows: amd64] Compiled at 2024-02-14 Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 3be251468365250a1ad2e86bb2fa634ff7297b61 active boot switches: -d:release

Current Output

.../test_backend.nim(9, 14) Error: internal error: environment misses: be

Expected Output

no error

Possible Solution

No response

Additional Information

It works with nim 1.6.18 and nim 2.1.1, only failed with nim 2.0.3

jangko avatar Feb 14 '24 21:02 jangko