fix interface conversion erroneously renaming colliding pattern names

This commit is contained in:
Zachary Snow 2021-06-23 21:39:15 -04:00
parent a15b0c735f
commit afc3ea435b
3 changed files with 31 additions and 1 deletions

View File

@ -468,7 +468,16 @@ inlineInstance global ranges modportBindings items partName
case lookup (Bit expr Tag) exprReplacements of
Just resolved -> replaceArrTag (replaceExpr' local elt) resolved
Nothing -> Bit (replaceExpr' local expr) (replaceExpr' local elt)
replaceExpr' local expr =
replaceExpr' local (expr @ (Dot Ident{} _)) =
case lookup expr exprReplacements of
Just expr' -> expr'
Nothing -> checkExprResolution local expr $
traverseSinglyNestedExprs (replaceExprAny local) expr
replaceExpr' local (Ident x) =
checkExprResolution local (Ident x) (Ident x)
replaceExpr' local expr = replaceExprAny local expr
replaceExprAny :: Scopes Expr -> Expr -> Expr
replaceExprAny local expr =
case lookup expr exprReplacements of
Just expr' -> expr'
Nothing -> checkExprResolution local expr $

View File

@ -0,0 +1,18 @@
interface Interface;
logic x;
endinterface
module Module (
Interface p
);
typedef struct packed {
integer p;
} S;
S s = '{ p: 1 };
initial $display("%0d %0d", s, s.p);
endmodule
module top;
Interface intf();
Module mod(intf);
endmodule

View File

@ -0,0 +1,3 @@
module top;
initial $display("%0d %0d", 1, 1);
endmodule