Skip to content

Implicit items not resolved cross-module when func has static param #25685

@etan-status

Description

@etan-status

Nim Version

Nim Compiler Version 2.2.8 [MacOSX: arm64]
Compiled at 2026-03-24
Copyright (c) 2006-2026 by Andreas Rumpf

git hash: 4f50067
active boot switches: -d:release

Description

lib.nim

import std/sets

func impl*(flag: static bool): seq[uint64] =
  var all = initHashSet[uint64]()
  all.incl 1
  for idx in all:  # fails cross-module
  # for idx in all.items():  # workaround
    result.add idx

template bar*(): seq[uint64] =
  impl(flag = true)

repro.nim

import lib
echo bar()

Current Output

//./repro.nim(2, 9) template/generic instantiation of `bar` from here
//./lib.nim(6, 14) Error: type mismatch
Expression: items(all)
  [1] all: HashSet[system.uint64]

Expected Output

Successful compile

Known Workarounds

Explicit .items() in the loop

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions