Skip to content

[FIRRTL] stop allowing duplicate field names in bundles #8601

Open
@youngar

Description

@youngar

In the FIRRTL spec, it says:

Within a bundle type declaration, all field names must be unique.

We don't have proper diagnosis of this error. For example, with

FIRRTL version 4.0.0
circuit Foo:
  public module Foo:
    input bundle : {a: UInt<8>, a: UInt<8>}
    output o : UInt<8>
    connect o, bundle.a

running firtool --preserve-aggregate=none. ./bundle.fir produces:

module Foo(
  input  [7:0] bundle_a,
               bundle_a_0,
  output [7:0] o
);

  assign o = bundle_a;
endmodule

and running firtool --preserve-aggregate=all. ./bundle.fir crashes with:

<unknown>:0: error: duplicate field name 'a' in hw.struct type
firtool: /scratch/aryoung/circt/llvm/llvm/../mlir/include/mlir/IR/StorageUniquerSupport.h:180: static ConcreteT mlir::detail::StorageUserBase<circt::hw::StructType, mlir::Type, circt::hw::detail::StructTypeStorage, mlir::detail::TypeUniquer, Trait, Trait>::get(mlir::MLIRContext *, Args &&...) [ConcreteT = circt::hw::StructType, BaseT = mlir::Type, StorageT = circt::hw::detail::StructTypeStorage, UniquerT = mlir::detail::TypeUniquer, Traits = <Trait, Trait>, Args = <llvm::ArrayRef<circt::hw::detail::FieldInfo>>]: Assertion `succeeded( ConcreteT::verifyInvariants(getDefaultDiagnosticEmitFn(ctx), args...))' failed.
PLEASE submit a bug report to https://github.com/llvm/circt and include the crash backtrace.
Stack dump:
0.      Program arguments: ./bin/firtool --preserve-aggregate=all ./bundle.fir

Metadata

Metadata

Assignees

No one assigned

    Labels

    FIRRTLInvolving the `firrtl` dialect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions