Introduce inst generic boundary#1192
Conversation
CodSpeed Performance ReportMerging #1192 will not alter performanceComparing Summary
|
e7c90ff to
60cf6da
Compare
| } | ||
| } | ||
| GenericBoundKind::Inst(proto) => { | ||
| let proto_match = if arg.is_resolvable() { |
There was a problem hiding this comment.
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
}There was a problem hiding this comment.
I added todo comments.
|
|
||
| let _a: StructH::<W> = 0; | ||
| } | ||
|
|
There was a problem hiding this comment.
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>;
}There was a problem hiding this comment.
I agree with you but a lot of changes is needed to introduce proto interface.
For now, how about removing this example and opening a new PR to introduce proto interface?
There was a problem hiding this comment.
I agree you. check_type.rs:387-390 and symbol.rs:304 should be removed probably.
There was a problem hiding this comment.
I removed changes to allow interface to be used as generic boundary.
59aa506 to
c353e61
Compare
inst generic boundary
crates/analyzer/src/symbol.rs
Outdated
| pub fn proto(&self) -> Option<SymbolPath> { | ||
| match &self.kind { | ||
| SymbolKind::Module(x) => x.proto.clone(), | ||
| SymbolKind::Interface(_) => Some((&self.token).into()), |
There was a problem hiding this comment.
Yes.
It is used at here.
There was a problem hiding this comment.
In this PR, interface can't be used as generic boudary. So I think adding SymbolKind::Interface(_) is not necessary, and SymbolKind::Interface(x) => x.proto.clone(), should be added at introducing proto interface.
There was a problem hiding this comment.
The inst boundary with specific interface is needed for usecase shown in #793.
Therefore, this change is needed.
There was a problem hiding this comment.
I understood this line is used, but I think it is not appropriate that non proto symbol returns Some from proto().
Changing proto() to proto_or_inst() or splitting it into proto() and inst() is better.
I prefer the splitting way because inst can be assigned to a generic parameter bound as proto if proto and inst are not distincted.
There was a problem hiding this comment.
I removed the statement for the SymbolKind::Interface but did not add the inst function.
Instead of the function, I added resolve_inst_generic_arg_type and resolve_proto_generic_arg_type functions to simplify resolving type of generic arguments.
There was a problem hiding this comment.
Thanks!
I think this is better than my idea.
314175c to
446f727
Compare
* introduce a new generic bound `inst` to specify module/interface instance
446f727 to
33f9eb6
Compare
This PR is to a new generic boundary named
inst.The
isntboundary is to specify module or interface instance as a generic parameter.refs: #963 (comment)