From 6844ed4194b095269c478af2b4d08dabe96e1df7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 8 Jul 2026 21:27:04 -0700 Subject: [PATCH] Accept type-identifier tokens in named binding selectors A named binding selector such as `.T(expr)` names an existing formal port, parameter, task or function argument, or constructor argument. It is not a declaration of a new identifier. If a visible typedef named `T` exists at the use site the lexer returns `TYPE_IDENTIFIER`, which made the parser reject the binding selector. Modport simple port aliases use the same grammar, but are slightly different: the selector is the modport-visible port name and can shadow a visible typedef name in the interface scope. Use `identifier_name` for the selector name in `named_expression` and `named_expression_opt`. This covers named parameter overrides, named task and function arguments, named constructor arguments, and modport simple port aliases. Also use `identifier_name` in the named module port connection rules, including implicit named port connections and error recovery. Signed-off-by: Lars-Peter Clausen --- parse.y | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parse.y b/parse.y index 6f9edcf15..b7d3a2e31 100644 --- a/parse.y +++ b/parse.y @@ -6089,7 +6089,7 @@ parameter_value_opt ; named_expression - : '.' IDENTIFIER '(' expression ')' + : '.' identifier_name '(' expression ')' { named_pexpr_t*tmp = new named_pexpr_t; FILE_NAME(tmp, @$); tmp->name = lex_strings.make($2); @@ -6100,7 +6100,7 @@ named_expression named_expression_opt : named_expression - | '.' IDENTIFIER '(' ')' + | '.' identifier_name '(' ')' { named_pexpr_t*tmp = new named_pexpr_t; FILE_NAME(tmp, @$); tmp->name = lex_strings.make($2); @@ -6190,7 +6190,7 @@ port_name { delete $1; $$ = $2; } - | attribute_list_opt '.' IDENTIFIER '(' error ')' + | attribute_list_opt '.' identifier_name '(' error ')' { yyerror(@3, "error: Invalid port connection expression."); named_pexpr_t*tmp = new named_pexpr_t; FILE_NAME(tmp, @$); @@ -6200,7 +6200,7 @@ port_name delete $1; $$ = tmp; } - | attribute_list_opt '.' IDENTIFIER + | attribute_list_opt '.' identifier_name { pform_requires_sv(@3, "Implicit named port connections"); named_pexpr_t*tmp = new named_pexpr_t; FILE_NAME(tmp, @$);