From 547c42752298c2dedf609cff9d5393a91ec81fdf Mon Sep 17 00:00:00 2001 From: dalance Date: Thu, 10 Oct 2024 16:17:20 +0900 Subject: [PATCH] Fix member access failure of generic instance --- crates/analyzer/src/symbol_table.rs | 16 ++++++++++++---- .../map/testcases/sv/56_generic_interface.sv.map | 2 +- testcases/sv/56_generic_interface.sv | 5 +++++ testcases/veryl/56_generic_interface.veryl | 3 +++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/crates/analyzer/src/symbol_table.rs b/crates/analyzer/src/symbol_table.rs index c056c1a6..188e0a31 100644 --- a/crates/analyzer/src/symbol_table.rs +++ b/crates/analyzer/src/symbol_table.rs @@ -241,11 +241,19 @@ impl SymbolTable { context.inner = true; } SymbolKind::Instance(ref x) => { - context.namespace = Namespace::default(); - for x in &x.type_name { - context.namespace.push(*x); + let path = SymbolPath::new(&x.type_name); + let symbol = self.resolve(&path, &context.namespace)?; + if let SymbolKind::GenericInstance(x) = &symbol.found.kind { + let symbol = self.symbol_table.get(&x.base).unwrap(); + context.namespace = symbol.inner_namespace(); + context.inner = true; + } else { + context.namespace = Namespace::default(); + for x in &x.type_name { + context.namespace.push(*x); + } + context.inner = true; } - context.inner = true; } SymbolKind::GenericInstance(ref x) => { let symbol = self.symbol_table.get(&x.base).unwrap(); diff --git a/testcases/map/testcases/sv/56_generic_interface.sv.map b/testcases/map/testcases/sv/56_generic_interface.sv.map index 1263b7c6..338c5504 100644 --- a/testcases/map/testcases/sv/56_generic_interface.sv.map +++ b/testcases/map/testcases/sv/56_generic_interface.sv.map @@ -1 +1 @@ -{"version":3,"file":"56_generic_interface.sv.map","sources":["../../../veryl/56_generic_interface.veryl"],"names":["","module","Module56",";","veryl_testcase___Interface56A__Package56A","u0","veryl_testcase___Interface56A__Package56B","u1","veryl_testcase___Interface56B__Package56A","u2","u4","veryl_testcase___Interface56B__Package56B","u3","endmodule","interface","logic","[","veryl_testcase_Package56A::X","]","_a","endinterface","veryl_testcase_Package56B::X","_b","package","Package56A","localparam","int unsigned","X","=","1","endpackage","Package56B","2"],"mappings":"AAAAA,AAAAC,sBAAOC,QAASC;IACZH,AAASI,0CAAJC,KAA8BF;IACnCH,AAASM,0CAAJC,KAA8BJ;IACnCH,AAASQ,0CAAJC,KAA8BN;IACnCH,AAASQ,0CAAJE,KAA8BP;IACnCH,AAASW,0CAAJC,KAAoBT;AAC7BU;;;AAGIC,mDAAmCX;IAC3BY,MAAKC,CAACC,gCAAIC,EAAdC,EAAehB;AACvBiB;;;AAFIN,mDAAmCX;IAC3BY,MAAKC,CAACK,gCAAIH,EAAdC,EAAehB;AACvBiB;;;AAGIN,mDAAgDX;IACxCY,MAAKC,CAACC,gCAAIC,EAAdI,EAAenB;AACvBiB;AAFIN,mDAAgDX;IACxCY,MAAKC,CAACK,gCAAIH,EAAdI,EAAenB;AACvBiB;;AAEAG,uBAAQC,UAAWrB;IACfsB,WAASC,aAAHC,EAAOC,EAAEC,CAAC1B;AACpB2B;;AAEAP,uBAAQQ,UAAW5B;IACfsB,WAASC,aAAHC,EAAOC,EAAEI,CAAC7B;AACpB2B"} \ No newline at end of file +{"version":3,"file":"56_generic_interface.sv.map","sources":["../../../veryl/56_generic_interface.veryl"],"names":["","module","Module56",";","veryl_testcase___Interface56A__Package56A","u0","veryl_testcase___Interface56A__Package56B","u1","veryl_testcase___Interface56B__Package56A","u2","u4","veryl_testcase___Interface56B__Package56B","u3","logic","_a","=",".","_b","endmodule","interface","[","veryl_testcase_Package56A::X","]","endinterface","veryl_testcase_Package56B::X","package","Package56A","localparam","int unsigned","X","1","endpackage","Package56B","2"],"mappings":"AAAAA,AAAAC,sBAAOC,QAASC;IACZH,AAASI,0CAAJC,KAA8BF;IACnCH,AAASM,0CAAJC,KAA8BJ;IACnCH,AAASQ,0CAAJC,KAA8BN;IACnCH,AAASQ,0CAAJE,KAA8BP;IACnCH,AAASW,0CAAJC,KAAoBT;;IAEjBU,MAAJC;mBAAUC,EAAEV,EAAEW,CAACF,EAAEX;IACbU,MAAJI;mBAAUF,EAAEN,EAAEO,CAACC,EAAEd;AACzBe;;;AAGIC,mDAAmChB;IAC3BU,MAAKO,CAACC,gCAAIC,EAAdR,EAAeX;AACvBoB;;;AAFIJ,mDAAmChB;IAC3BU,MAAKO,CAACI,gCAAIF,EAAdR,EAAeX;AACvBoB;;;AAGIJ,mDAAgDhB;IACxCU,MAAKO,CAACC,gCAAIC,EAAdL,EAAed;AACvBoB;AAFIJ,mDAAgDhB;IACxCU,MAAKO,CAACI,gCAAIF,EAAdL,EAAed;AACvBoB;;AAEAE,uBAAQC,UAAWvB;IACfwB,WAASC,aAAHC,EAAOd,EAAEe,CAAC3B;AACpB4B;;AAEAN,uBAAQO,UAAW7B;IACfwB,WAASC,aAAHC,EAAOd,EAAEkB,CAAC9B;AACpB4B"} \ No newline at end of file diff --git a/testcases/sv/56_generic_interface.sv b/testcases/sv/56_generic_interface.sv index 515ac5ff..a1ac90f0 100644 --- a/testcases/sv/56_generic_interface.sv +++ b/testcases/sv/56_generic_interface.sv @@ -4,6 +4,11 @@ module veryl_testcase_Module56; veryl_testcase___Interface56B__Package56A u2 (); veryl_testcase___Interface56B__Package56A u4 (); veryl_testcase___Interface56B__Package56B u3 (); + + logic _a; + always_comb _a = u0._a; + logic _b; + always_comb _b = u2._b; endmodule /// Generic interface test for doc comment diff --git a/testcases/veryl/56_generic_interface.veryl b/testcases/veryl/56_generic_interface.veryl index 27269530..2c6092ff 100644 --- a/testcases/veryl/56_generic_interface.veryl +++ b/testcases/veryl/56_generic_interface.veryl @@ -4,6 +4,9 @@ module Module56 { inst u2: Interface56B::; inst u4: Interface56B::; inst u3: Interface56B::<>; + + let _a: logic = u0._a; + let _b: logic = u2._b; } /// Generic interface test for doc comment