Skip to content

Commit

Permalink
Merge pull request #881 from veryl-lang/suppress_unused_generics
Browse files Browse the repository at this point in the history
Suppress to emit unused generics
  • Loading branch information
dalance authored Aug 13, 2024
2 parents 884d139 + e9bbbc8 commit b61173a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/analyzer/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Symbol {
}

// empty map for non-generic
if ret.is_empty() {
if ret.is_empty() && !self.kind.is_generic() {
ret.push(GenericMap::default());
}
ret
Expand Down Expand Up @@ -307,6 +307,18 @@ impl SymbolKind {
SymbolKind::ClockDomain => "clock domain".to_string(),
}
}

pub fn is_generic(&self) -> bool {
match self {
SymbolKind::Module(x) => !x.generic_parameters.is_empty(),
SymbolKind::Interface(x) => !x.generic_parameters.is_empty(),
SymbolKind::Function(x) => !x.generic_parameters.is_empty(),
SymbolKind::Package(x) => !x.generic_parameters.is_empty(),
SymbolKind::Struct(x) => !x.generic_parameters.is_empty(),
SymbolKind::Union(x) => !x.generic_parameters.is_empty(),
_ => false,
}
}
}

impl fmt::Display for SymbolKind {
Expand Down
1 change: 1 addition & 0 deletions testcases/sv/55_generic_module.sv
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ endmodule
module veryl_testcase___Module55F__Module55B;
veryl_testcase_Module55B u ();
endmodule

//# sourceMappingURL=../map/testcases/sv/55_generic_module.sv.map
4 changes: 4 additions & 0 deletions testcases/veryl/55_generic_module.veryl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ module Module55E::<T> {
module Module55F::<T = Module55B> {
inst u: T;
}

module Module55G::<T> {
inst u: T;
}

0 comments on commit b61173a

Please sign in to comment.