Skip to content

Commit

Permalink
Fix inference of parameters from large based integer literals
Browse files Browse the repository at this point in the history
  • Loading branch information
MikePopoloski committed Sep 4, 2023
1 parent 7486826 commit a93aa7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/ast/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ std::tuple<const Expression*, const Type*> Expression::bindImplicitParam(
if (lhsType->isIntegral()) {
bitwidth_t bits = lhsType->getBitWidth();
if (expr.isUnsizedInteger())
bits = 32;
bits = std::max(bits, 32u);

// Keep the signed flag but force four state.
auto flags = lhsType->getIntegralFlags();
Expand Down
15 changes: 15 additions & 0 deletions tests/unittests/ast/ExpressionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2956,3 +2956,18 @@ endclass
compilation.addSyntaxTree(tree);
NO_COMPILATION_ERRORS;
}

TEST_CASE("Type of unsized based literal") {
auto tree = SyntaxTree::fromText(R"(
module m;
parameter p = 'd999999999999;
endmodule
)");

Compilation compilation;
compilation.addSyntaxTree(tree);
NO_COMPILATION_ERRORS;

auto& p = compilation.getRoot().lookupName<ParameterSymbol>("m.p");
CHECK(p.getType().toString() == "logic[39:0]");
}

0 comments on commit a93aa7c

Please sign in to comment.