Estimated hours taken: 5
Fix a bug in the optimization where polymorphism.m passes a
base_type_info in place of a type_info for non-polymorphic types.
The type of the variable was `base_type_info' not `type_info'.
This caused inlining.m to be unable to compute a type substitution,
and code_util__cons_id_to_tag aborted on an unsubstituted type
variable.
compiler/mercury_builtin.m
compiler/code_util.m
Add a new builtin, unsafe_type_cast/2, used by common.m
to preserve type correctness.
Make unsafe_promise_unique/2 a builtin, since it is basically
the same as unsafe_type_cast/2.
compiler/polymorphism.m
Set the type of a `base_type_info' passed where a `type_info'
is expected to `type_info'.
Don't add the type_info argument for unsafe_type_cast, since it is
not needed and would make the code in common.m more complicated.
compiler/common.m
Generate a call to unsafe_type_cast rather than an assignment
unification when the assignment would not be type correct.
tests/valid/inlining_bug.m
Regression test.
tests/general/common_type_cast.m
tests/general/common_type_cast.exp
Test of type casts.