Fix type resolution when a local name shadows a type name
Co-Authored-By: Adam Kostrzewski <akostrzewski@internships.antmicro.com> Signed-off-by: Pawel Klopotek <pklopotek@internships.antmicro.com>
This commit is contained in:
parent
3c7727a8f4
commit
f2e55c1cdf
|
|
@ -3572,9 +3572,13 @@ class LinkDotResolveVisitor final : public VNVisitor {
|
|||
while (lookp) {
|
||||
VSymEnt* const foundp = lookp->findIdFlat(name);
|
||||
if (foundp && !VN_IS(foundp->nodep(), MemberDType)) {
|
||||
// A variable is not a type candidate (IEEE 1800-2023 6.18); skip it so an
|
||||
// enclosing type is found, but keep it to preserve the "found: VAR" error.
|
||||
if (!VN_IS(foundp->nodep(), Var)) return foundp;
|
||||
// Non-type entries are not type candidates
|
||||
// (IEEE 1800-2023 6.18); skip them so an enclosing
|
||||
// type is found, but keep one to preserve the "found: ..." error.
|
||||
if (VN_IS(foundp->nodep(), Typedef) || VN_IS(foundp->nodep(), ParamTypeDType)
|
||||
|| VN_IS(foundp->nodep(), Class)) {
|
||||
return foundp;
|
||||
}
|
||||
if (!shadowEntp) shadowEntp = foundp;
|
||||
}
|
||||
lookp = lookp->fallbackp();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
// DESCRIPTION: Verilator: Verilog Test module
|
||||
//
|
||||
// This file ONLY is placed under the Creative Commons Public Domain.
|
||||
// SPDX-FileCopyrightText: 2026 Antmicro
|
||||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
module t;
|
||||
class B;
|
||||
function void B();
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
class A;
|
||||
B b = B::new();
|
||||
|
||||
function void B();
|
||||
b.B();
|
||||
$write("*-* All Finished *-*\n");
|
||||
$finish;
|
||||
endfunction
|
||||
endclass
|
||||
|
||||
initial begin
|
||||
static A a = A::new();
|
||||
a.B();
|
||||
end
|
||||
endmodule
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env python3
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of either the GNU Lesser General Public License Version 3
|
||||
# or the Perl Artistic License Version 2.0.
|
||||
# SPDX-FileCopyrightText: 2026 Wilson Snyder
|
||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
import vltest_bootstrap
|
||||
|
||||
test.scenarios('simulator')
|
||||
|
||||
test.compile()
|
||||
|
||||
test.execute()
|
||||
|
||||
test.passes()
|
||||
|
|
@ -34,12 +34,16 @@ class parent;
|
|||
rand my_blk my_blk;
|
||||
endclass
|
||||
|
||||
class Cls;
|
||||
endclass
|
||||
|
||||
module t;
|
||||
my_t my_t; // also legal at module scope
|
||||
|
||||
initial begin
|
||||
static C c = new;
|
||||
static parent p = new;
|
||||
static Cls Cls = new;
|
||||
c.my_t = 8'hAB;
|
||||
p.my_blk = new;
|
||||
p.my_blk.x = 5;
|
||||
Loading…
Reference in New Issue