chipsalliance / chipsalliance/chisel
Bad error message for switch(){is()} if multiple is() with same value.
- Dominant language
- Scala
- Stars
- 4.8k
- Forks
- 658
- Avg merge
- 18h 59m
- Merged PRs (30d)
- 14
Description
**Type of issue**: bug report
**Impact**: no functional change
**Development Phase**: request
**What is the current behavior?**
If we have several identical is() value in a switch like this :
```scala
switch(count) {
is(0.U){
...
}
is(1.U) {
...
}
is(1.U) {
...
}
}
```
We get Scala generic error trace that is very obscure :
```
[error] (run-main-0) firrtl.options.OptionsException: Exception thrown when elaborating ChiselGeneratorAnnotation
[error] firrtl.options.OptionsException: Exception thrown when elaborating ChiselGeneratorAnnotation
[error] at chisel3.stage.ChiselGeneratorAnnotation.elaborate(ChiselAnnotations.scala:55)
[error] at chisel3.stage.phases.Elaborate.$anonfun$transform$1(Elaborate.scala:19)
[error] at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245)
...
[error] at scala.App.$anonfun$main$1$adapted(App.scala:80)
[error] at scala.collection.immutable.List.foreach(List.scala:392)
[error] at scala.App.main(App.scala:80)
[error] at scala.App.main$(App.scala:78)
[error] at spi2ksz.Spi2Ksz$.main(spi2ksz.scala:263)
[error] at spi2ksz.Spi2Ksz.main(spi2ksz.scala)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:498)
[error] Nonzero exit code: 1
[error] (Compile / runMain) Nonzero exit code: 1
[error] Total time: 23 s, completed 7 nov. 2019 16:27:55
```
**What is the expected behavior?**
If we could have a clearer message it would be good no ?
Contributor guide
Research direction
Reproduce the issue with the switch(count) example containing two identical is(1.U) cases and start from the ChiselGeneratorAnnotation elaboration path named in the stack trace. Trace how duplicate switch values are reported and make the resulting diagnostic identify the duplicate value clearly, then verify the revised message against the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100