Skip to content

Commit

Permalink
[MooreToCore] Return early on non-convertable type (#7631)
Browse files Browse the repository at this point in the history
  • Loading branch information
maerhart authored Sep 25, 2024
1 parent 77f49fb commit 7c80a60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Conversion/MooreToCore/MooreToCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ struct VariableOpConversion : public OpConversionPattern<VariableOp> {
ConversionPatternRewriter &rewriter) const override {
Location loc = op.getLoc();
Type resultType = typeConverter->convertType(op.getResult().getType());
if (!resultType)
return rewriter.notifyMatchFailure(op.getLoc(), "invalid variable type");

// Determine the initial value of the signal.
Value init = adaptor.getInitial();
Expand Down
8 changes: 8 additions & 0 deletions test/Conversion/MooreToCore/errors.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: circt-opt --convert-moore-to-core --split-input-file --verify-diagnostics

func.func @invalidType() {
// expected-error @below {{failed to legalize operation 'moore.variable'}}
%var = moore.variable : <!moore.queue<string, 42>>

return
}

0 comments on commit 7c80a60

Please sign in to comment.