Skip to content

Commit

Permalink
Merge pull request #1009 from veryl-lang/fix_generic_member
Browse files Browse the repository at this point in the history
Fix member access failure of generic instance
  • Loading branch information
dalance authored Oct 10, 2024
2 parents 4cdbd7a + 547c427 commit f4e293c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
16 changes: 12 additions & 4 deletions crates/analyzer/src/symbol_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion testcases/map/testcases/sv/56_generic_interface.sv.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions testcases/sv/56_generic_interface.sv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions testcases/veryl/56_generic_interface.veryl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module Module56 {
inst u2: Interface56B::<Package56A>;
inst u4: Interface56B::<Package56A>;
inst u3: Interface56B::<>;

let _a: logic = u0._a;
let _b: logic = u2._b;
}

/// Generic interface test for doc comment
Expand Down

0 comments on commit f4e293c

Please sign in to comment.