mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-21 00:39:37 +00:00
Estimated hours taken: 5 library/std_util.m: Fix a bug in ML_create_type_info(): when searching for type parameters to substituting with their corresponding values, they were only looking at the top level of the type. To get correct results, it is necessary to traverse recursively through all levels of the type. runtime/mercury_deep_copy.c: Fix a bug similar to the one above in make_type_info(). The fix is a bit more complicated, due to memory management issues --- we need to keep a linked list of all the memory cells we allocate so that we can free them when we're done. Also avoid some duplicated code in mercury_deep_copy.c by introducing a new function deep_copy_arg(). And fix a bug in deep_copy_type_info(): it should be allocating memory using incr_saved_hp(), not using make(). make() calls newmem(), which in non-conservative GC grades calls malloc(), which results in a memory leak; whereas incr_saved_hp() allocates on the Mercury heap, which is (in accurate gc grades) subject to garbage collection. tests/hard_coded/Mmakefile: tests/hard_coded/eqv_type_bug.m: tests/hard_coded/eqv_type_bug.exp: Regression test for the above-mentioned bug in ML_create_type_info().