Skip to content
Snippets Groups Projects
Commit d09efff4 authored by Russel Arbore's avatar Russel Arbore
Browse files

handle const prop in dyn const eq check

parent c83bc41f
No related branches found
No related tags found
1 merge request!111Normalize dynamic constants during typechecking
Pipeline #201027 passed
......@@ -1128,7 +1128,8 @@ fn types_match(
/*
* Determine if the given dynamic constant matches the parameter's dynamic
* constants when the provided dynamic constants are substituted in for the
* dynamic constants used in the parameter's dynamic constant
* dynamic constants used in the parameter's dynamic constant. Implement dynamic
* constant normalization here as well - i.e., 1 * 2 * 3 = 6.
*/
fn dyn_consts_match(
dynamic_constants: &Vec<DynamicConstant>,
......@@ -1136,6 +1137,14 @@ fn dyn_consts_match(
param: DynamicConstantID,
input: DynamicConstantID,
) -> bool {
// First, try evaluating the DCs and seeing if they're the same value.
if let (Some(cons1), Some(cons2)) = (
evaluate_dynamic_constant(param, dynamic_constants),
evaluate_dynamic_constant(input, dynamic_constants),
) {
return cons1 == cons2;
}
match (
&dynamic_constants[param.idx()],
&dynamic_constants[input.idx()],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment