[FIRRTL] Don't allow annotations to target enumeration variants
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
I don't think that it makes sense for annotations to target a variant of an enumeration type as if it were a regular aggregate. In the following example, the annotation should not be able to target the `X` variant.
```firrtl
circuit Foo: %[[
{
"class":"firrtl.transforms.DontTouchAnnotation",
"target":"~Foo|Foo>w.X"
}
]]
module Foo:
wire w : {| X |}
w is invalid
```
Right now, `firtool` gives the following error message:
```
./test.fir:8:5: error: field access 'X' into non-bundle type ''<>''
wire w : {| X |}
^
./test.fir:8:5: note: see current operation: %0 = "firrtl.wire"() {annotations = [], name = "w", nameKind = #firrtl} : () -> !firrtl.enum>
./test.fir:1:1: error: Unable to resolve target of annotation: {class = "firrtl.transforms.DontTouchAnnotation", target = "~Foo|Foo>w.X"}
circuit Foo: %[[
^
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the FIRRTL example with firtool and inspect how annotation targets resolve field access on enumeration types. The change is done when an annotation cannot target the X enumeration variant as though it were an aggregate, with an appropriate diagnostic and no misleading field-access failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100