-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance generic boundary #1192
base: master
Are you sure you want to change the base?
Enhance generic boundary #1192
Conversation
CodSpeed Performance ReportMerging #1192 will not alter performanceComparing Summary
|
631a4d5
to
e7c90ff
Compare
* allow to use interface as generic bound * introduce a new generic bound `inst` to specify module/interface instance
e7c90ff
to
60cf6da
Compare
@@ -210,12 +210,62 @@ impl VerylGrammarTrait for CheckType<'_> { | |||
)); | |||
} | |||
} | |||
GenericBoundKind::Inst(proto) => { | |||
let proto_match = if arg.is_resolvable() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At Rust 2024 (Rust 1.85), if-let chain will be stabilized.
After it, this large if chain can be re-written like below. So TODO
comment may be useful to mark for re-writing.
if arg.is_resolvable()
&& let Ok(symbol) = ...
&& let SymbolKind::Instance(x) = ...
&& let Ok(x) = ...
&& let Some(ref x) = x.found.proto() {
...
} else {
false
}
@@ -41,3 +42,9 @@ module Module55H::<W: const> { | |||
|
|||
let _a: StructH::<W> = 0; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this example is bit strange.
IF
is bound by Interface55I
, but Interface55I
is not proto
but specific type, so IF
is always Interface55I
.
Therefore I think generics is not required in this case.
How about adding proto interface
support described at #963 like below?
proto interface PInterface {
function FuncA(a: input logic, b: input logic) -> logic;
}
interface Interface55I for PInterface {
function FuncA(a: input logic, b: input logic) -> logic {
return 0;
}
}
module Module55I::<IF: PInterface> {
inst u: IF;
}
module X {
inst u: Module55I::<Interface55I>;
}
This PR is to enhance generic bound. Details are blow.
inst
to specify module/interface instance