llvm / llvm/circt

[FIRRTL] Can't parse const enum (and therefore can't parse enum w/const elements)

Open
#5,884 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug FIRRTL
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

Enum's must be const if their elements are const, but the way we parse constructs a non-const enum (with the parsed element types) before converting it to const.

Consider:

circuit EnumConst:
  module EnumConst:
    input e : {| Some : const UInt<8>, None |}

Which is invalid and should diagnose the invalid enum type.

or this legal enum:

circuit ConstEnumConst:
  module ConstEnumConst:
    input e : const {| Some : const UInt<8>, None |}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the FIRRTL parser path that handles enum types and reproduce the two examples from the issue. Done means the enum with a const element is diagnosed as invalid, while the const enum containing a const element parses successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.