mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-20 16:31:04 +00:00
Estimated hours taken: 8 Branches: main compiler/inst_match.m: Fix a bug which was causing the mode system to be overly-conservative: pred_inst_matches was requiring initial insts of higher-order arguments to match invariantly rather than contravariantly. The bug was caused by my change to add support for mode polymorphism. In that change I added a call to inst_matches_initial to compute the inst variable substitution for the higher-order inst. This change modifies inst_matches_final to compute the substitution that was previously computed by inst_matches_initial, thus allowing the call to inst_matches_initial to be removed. However, because the initial inst test is required to be contravariant, the call to inst_matches_final swaps the argument insts. We must allow for this inside inst_matches_final when computing the substitution. Also add a predicate inst_matches_initial_no_implied_modes which is similar to inst_matches_initial, but does not allow implied modes to match. The predicate inst_matches_final was previously being used for this task, but it does not handle constrained inst variables correctly. compiler/modecheck_call.m: compiler/modes.m: Use inst_matches_initial_no_implied_modes instead of inst_matches_final, where appropriate. tests/hard_coded/Mmakefile: tests/hard_coded/contravariance_bug.m: tests/hard_coded/contravariance_bug.exp: Add a test case supplied by Fergus. tests/hard_coded/Mmakefile: tests/hard_coded/contravariance_poly.m: tests/hard_coded/contravariance_poly.exp: Add another test case, similar to the above, but using polymorphic modes.
2 lines
4 B
Plaintext
2 lines
4 B
Plaintext
yes
|