From ca5c6fc59f47eb69767d8bffd0f1e77609ab3f67 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 5 Jul 2026 14:39:43 -0700 Subject: [PATCH] Support package names shadowing type identifiers SystemVerilog allows a package declaration to use a name that is also visible as a type identifier. The lexer reports such names as `TYPE_IDENTIFIER` before the package has been installed, which made constructs such as: package p; typedef int T; endpackage import p::*; package T; endpackage fail in the package declaration grammar. Package declarations do not have the local type/name ambiguity that exists for variable, net, or parameter declarations. After the optional lifetime the next token is always the package name. Use `identifier_name` so a `TYPE_IDENTIFIER` token can be accepted as the package name. Signed-off-by: Lars-Peter Clausen --- parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parse.y b/parse.y index f94ceccf1..b7c71c8bf 100644 --- a/parse.y +++ b/parse.y @@ -2359,7 +2359,7 @@ open_range_list /* IEEE1800-2005 A.2.11 */ ; package_declaration /* IEEE1800-2005 A.1.2 */ - : K_package lifetime_opt IDENTIFIER ';' + : K_package lifetime_opt identifier_name ';' { pform_start_package_declaration(@1, $3, $2); } timeunits_declaration_opt { pform_set_scope_timescale(@1); }