Skip to content

Enums with holes are iterable #1982

@def-

Description

@def-

The manual states here http://nim-lang.org/manual.html#enumeration-types :

type
  TokenType = enum
    a = 2, b = 4, c = 89 # holes are valid

However, it is then not an ordinal anymore, so it is not possible to use these enums as an index type for arrays. The procedures inc, dec, succ and pred are not available for them either.

But I can iterate over this:

for i in TokenType.low .. TokenType.high:
  echo i

Either the documentation should be updated or the implementation fixed.

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