@@ -137,6 +137,16 @@ UnifyRules::commit (TyTy::BaseType *base, TyTy::BaseType *other,
137
137
// if any of the types are inference variables lets fix them
138
138
if (ref_tyty->is <TyTy::InferType> ())
139
139
context.insert_implicit_type (ref, resolved);
140
+ else if (resolved->is <TyTy::ConstType> ()
141
+ && ref_tyty->is <TyTy::ConstType> ())
142
+ {
143
+ auto &const_expr = *static_cast <TyTy::ConstType *> (resolved);
144
+ if (const_expr.get_const_kind ()
145
+ == TyTy::ConstType::ConstKind::Value)
146
+ {
147
+ context.insert_implicit_type (ref, resolved);
148
+ }
149
+ }
140
150
}
141
151
}
142
152
}
@@ -264,6 +274,35 @@ UnifyRules::go ()
264
274
// set the rtype now to the new inference var
265
275
ltype = i;
266
276
}
277
+ else if (ltype->is <TyTy::ConstType> () && rtype->is <TyTy::ConstType> ())
278
+ {
279
+ const auto &lhs = *static_cast <TyTy::ConstType *> (ltype);
280
+ const auto &rhs = *static_cast <TyTy::ConstType *> (rtype);
281
+
282
+ bool both_are_decls
283
+ = lhs.get_const_kind () == TyTy::ConstType::ConstKind::Decl
284
+ && rhs.get_const_kind () == TyTy::ConstType::ConstKind::Decl;
285
+ bool have_decls
286
+ = lhs.get_const_kind () == TyTy::ConstType::ConstKind::Decl
287
+ || rhs.get_const_kind () == TyTy::ConstType::ConstKind::Decl;
288
+
289
+ if (have_decls && !both_are_decls)
290
+ {
291
+ if (lhs.get_const_kind () == TyTy::ConstType::ConstKind::Decl)
292
+ {
293
+ TyTy::TyVar iv = TyTy::TyVar::get_implicit_const_infer_var (
294
+ lhs, lhs.get_locus ());
295
+ ltype = iv.get_tyty ();
296
+ }
297
+ else if (rhs.get_const_kind ()
298
+ == TyTy::ConstType::ConstKind::Decl)
299
+ {
300
+ TyTy::TyVar iv = TyTy::TyVar::get_implicit_const_infer_var (
301
+ rhs, rhs.get_locus ());
302
+ rtype = iv.get_tyty ();
303
+ }
304
+ }
305
+ }
267
306
}
268
307
269
308
if ((ltype->is <TyTy::ConstType> () || rtype->is <TyTy::ConstType> ())
0 commit comments