Conversation
7eaf714 to
4000a7d
Compare
4000a7d to
cf460b6
Compare
richmckeever
left a comment
There was a problem hiding this comment.
Let's add tests in typecheck_module_v2_test to prove that for example it's OK to have disparate types in the branches of the const if in a function like:
fn f<N: u32>() -> uN[N] {
const if (N == 1) {
u1:0
} else {
zero!<uN[N]>();
}
}
b29930e to
10c3f0e
Compare
|
I've applied changes requested in the review. This previously failed due to wrong I've also included an example with conditional proc spawning. In order to spawn procs in FYI @richmckeever |
|
@richmckeever can you re-review and approve? |
10c3f0e to
fbee8cd
Compare
|
I've rebased these changes on |
Signed-off-by: Robert Winkler <rwinkler@antmicro.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Co-authored-by: Robert Winkler <rwinkler@antmicro.com> Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Internal-tag: #[80074]
Internal-tag: #[80074]
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
fbee8cd to
34726c9
Compare
|
I've rebased these changes on main and removed a change from the deleted |
This PR adds support for the constexpr
ifexpression.Information about the
constmodifier is stored in theConditionalclass and used later during type checking. For constexprif, separate type variables are assigned to each branch of the condition. At this stage, the result is not directly bound to them. During theTypeInfogeneration, the constexpr condition is evaluated, and one branch of the if is selected. Its type is unified, and the entire if is annotated with that type. The bytecode emitter and IR converter have been updated to inline the selected branch, skipping the unchosen one.Proper tests for this feature are still needed and will be added soon.
One issue not yet handled correctly in this PR is the conditional spawning of procs, for which an example has been added that shows the problem. Currently, all spawns affect the type, which should not happen as only the selected branch of constexpr
ifshould be considered. One possible approach is to enable constexpr evaluator in thePopulateInferenceTableVisitorand skip traversing the branch that was not taken. However, thePopulateInferenceTableVisitordoes not have access to the parametric environment, and the condition relying on the parametrics seems to be the most imprtant use-case for using constexprifwhen spawning procs.