···36343634 } => {
36353635 let constructor = self.infer_value_constructor(&module, &name, &location)?;
3636363636373637- let (tag, field_map) = match &constructor.variant {
36373637+ let (tag, field_map, variant_index) = match &constructor.variant {
36383638 ValueConstructorVariant::Record {
36393639- name, field_map, ..
36403640- } => (name.clone(), field_map.clone()),
36393639+ name,
36403640+ field_map,
36413641+ variant_index,
36423642+ ..
36433643+ } => (name.clone(), field_map.clone(), *variant_index),
3641364436423645 ValueConstructorVariant::ModuleFn { .. }
36433646 | ValueConstructorVariant::LocalVariable { .. } => {
···36703673 .clone();
36713674 let module_value_constructor = ModuleValueConstructor::Record {
36723675 name: name.clone(),
36763676+ variant_index,
36733677 field_map: field_map.clone(),
36743678 arity: args.len() as u16,
36753679 type_: Arc::clone(&type_),
···50095013 args: args_other,
50105014 ..
50115015 },
50125012- ) => {
50135013- if fun_one.is_record_builder() && fun_other.is_record_builder() {
50165016+ ) => match (fun_one.variant_index(), fun_other.variant_index()) {
50175017+ // Both have to be literal record builders, otherwise we can't really tell
50185018+ // anything at compile time!
50195019+ (None, None) | (None, Some(_)) | (Some(_), None) => StaticComparison::CantTell,
50205020+50215021+ // If they're both literal record builders and are building different
50225022+ // variants, then we know they'll always be different.
50235023+ (Some(index_one), Some(index_other)) if index_one != index_other => {
50245024+ StaticComparison::CertainlyDifferent
50255025+ }
50265026+50275027+ // Otherwise we need to check their arguments pairwise:
50285028+ (Some(_), Some(_)) => {
50145029 let mut comparison = StaticComparison::CertainlyEqual;
50155030 for (one, other) in args_one.iter().zip(args_other.iter()) {
50165031 match static_compare(&one.value, &other.value) {
50175032 StaticComparison::CertainlyEqual => (),
50335033+ // If we can tell any of the arguments are never going to
50345034+ // be the same then we can short circuit and be sure
50355035+ // that the two variants are not the same as well!
50185036 StaticComparison::CertainlyDifferent => {
50195037 return StaticComparison::CertainlyDifferent;
50205038 }
50395039+ // If we can't compare two of the arguments then there's
50405040+ // nothing we can tell at compile time. Notice how we
50415041+ // don't short circuit here: we still want to go over all
50425042+ // the other arguments because we might find two that are
50435043+ // certainly going to be different!
50215044 StaticComparison::CantTell => comparison = StaticComparison::CantTell,
50225045 }
50235046 }
50245047 comparison
50255025- } else {
50265026- StaticComparison::CantTell
50275048 }
50285028- }
50495049+ },
5029505050305051 (
50315052 TypedExpr::RecordAccess {