[m-rev.] for review: Make qualify_cons_id not return cons_ids containing dummy type_ctor.

Peter Wang novalazy at gmail.com
Thu May 6 13:46:15 AEST 2021


compiler/prog_type.m:
    Make qualify_cons_id return the same cons_id for types and insts,
    with the type_ctor field set correctly instead of a dummy type_ctor.
    The old behaviour was the source of cons_ids in insts with dummy
    type_ctor values AFTER post-typecheck.

compiler/modecheck_coerce.m:
    Resolve a question related this to fix.

diff --git a/compiler/modecheck_coerce.m b/compiler/modecheck_coerce.m
index c73a2bf66..f76b6beab 100644
--- a/compiler/modecheck_coerce.m
+++ b/compiler/modecheck_coerce.m
@@ -681,16 +681,11 @@ modecheck_coerce_from_ground_make_bound_functor(ModuleInfo, TVarSet,
     cons_id::out(cons)) is det.
 
 make_cons_id_for_type_ctor(TypeCtor, ConsId0, ConsId) :-
-    ConsId0 = cons(SymName0, Arity, TypeCtor0),
+    % TypeCtor0 should not be cons_id_dummy_type_ctor after post-typecheck.
+    ConsId0 = cons(SymName0, Arity, _TypeCtor0),
     ModuleName = type_ctor_module(TypeCtor),
     maybe_change_module_qualifier(ModuleName, SymName0, SymName),
-    ( if TypeCtor0 = cons_id_dummy_type_ctor then
-        % Keep the dummy type_ctor from the original cons_id.
-        % XXX TypeCtor0 should not be a dummy after post-typecheck.
-        ConsId = cons(SymName, Arity, TypeCtor0)
-    else
-        ConsId = cons(SymName, Arity, TypeCtor)
-    ).
+    ConsId = cons(SymName, Arity, TypeCtor).
 
 :- pred maybe_change_module_qualifier(sym_name::in, sym_name::in,
     sym_name::out) is det.
diff --git a/compiler/prog_type.m b/compiler/prog_type.m
index 40f5538da..4d488bc33 100644
--- a/compiler/prog_type.m
+++ b/compiler/prog_type.m
@@ -923,12 +923,11 @@ qualify_cons_id(Args, ConsId0, ConsId, InstConsId) :-
         ( if TypeCtor = type_ctor(qualified(TypeModule, _), _) then
             UnqualName = unqualify_name(Name0),
             Name = qualified(TypeModule, UnqualName),
-            ConsId = cons(Name, OrigArity, TypeCtor),
-            InstConsId = cons(Name, OrigArity, cons_id_dummy_type_ctor)
+            ConsId = cons(Name, OrigArity, TypeCtor)
         else
-            ConsId = ConsId0,
-            InstConsId = cons(Name0, OrigArity, cons_id_dummy_type_ctor)
-        )
+            ConsId = ConsId0
+        ),
+        InstConsId = ConsId
     ;
         ConsId0 = type_info_cell_constructor(CellCtor),
         ConsId = ConsId0,
-- 
2.30.0



More information about the reviews mailing list