Skip to content

mutable iterator cannot yield named tuples #12945

Closed
@disruptek

Description

@disruptek

This does not compile and I think it should.

iterator pairs*[K, V](group: Group[K, V]): (K, V) =
  for key, value in group.table.pairs:
    yield (key: key, val: value)

iterator mpairs*[K, V](group: Group[K, V]): (K, var V) =
  for key, value in group.table.mpairs:
    yield (key: key, val: value)  # compiler error
    yield (key, value)            # compiles

Nim Compiler Version 1.0.4 [Linux: amd64]
Compiled at 2019-12-16
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 97e0ce3c75c9348226ea1fcdfc601c6fbe5c0e75
active boot switches: -d:danger

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions