Files
mercury/tests/invalid/coerce_uniq.err_exp
Peter Wang 7bcab5e7bd Implement modechecking of coerce more efficiently.
Implement modechecking of coerce in a direct and efficient way.
The old implementation worked by generating a 'bound' inst node for each
node in the type tree (recursively, as far as possible),
calling abstractly_unify_inst, then checking the resulting inst is valid
for the result type. The insts could explode in size for large types.

The new implementation works by simultaneously traversing the input inst
tree, the input type tree, and the result type tree, and producing the
result inst tree for a valid conversion or rejecting the coercion.
Where the input and result types are equal, the result inst can just be
'ground' instead of expanding to a 'bound' inst. Therefore the
result inst does not explode in size compared to the input inst.

While testing, I discovered a couple of cases where the old
implementation would accept coercions that it should not have,
which are rejected by the new implementation.

compiler/modecheck_coerce.m:
    Implement the new algorithm.

compiler/mode_errors.m:
    Change how we report coerce mode errors as we cannot generate the
    same messages as before.

compiler/typecheck.m:
compiler/type_util.m:
    Move get_supertype into type_util.m.

doc/reference_manual.texi:
    Describe how coerce is mode checked now.

tests/invalid/Mmakefile:
tests/invalid/coerce_int.err_exp:
tests/invalid/coerce_int.m:
tests/invalid/coerce_recursive_inst.err_exp:
tests/invalid/coerce_recursive_inst.m:
tests/invalid/coerce_recursive_type.err_exp:
tests/invalid/coerce_recursive_type.m:
    Add new test cases.

tests/invalid/coerce_mode_error.m:
tests/invalid/coerce_mode_error.err_exp:
tests/invalid/coerce_instvar.err_exp:
tests/invalid/coerce_uniq.err_exp:
tests/invalid/coerce_unreachable.err_exp:
    Update expected error messages.
2021-05-05 16:21:13 +10:00

6 lines
291 B
Plaintext

coerce_uniq.m:024: In clause for `coerce_ui(ui, out)':
coerce_uniq.m:024: mode error: argument 1 did not get sufficiently
coerce_uniq.m:024: instantiated.
coerce_uniq.m:024: Final instantiatedness of `X' was `ground',
coerce_uniq.m:024: expected final instantiatedness was `unique'.