Mercury Bugs - mercury
View Issue Details
0000359mercuryBugpublic2014-09-05 17:312018-03-06 15:45
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000359: constrained polymorphic modes
DescriptionSaving test cases to fix some other time.
TagsNo tags attached.
Attached Files? lambda.m (548) 2014-09-05 17:31
? ho_constrained_poly_inst.m (269) 2018-03-06 15:24
? create_test_unification.m (393) 2018-03-06 15:41

2014-10-09 11:44   
The problem in lambda.m:
2015-07-15 11:37   
A workaround for this is to use an explicit pred expression. For the lambda.m example, write:

    P = (pred(Z::out(bound(1))) is det :- id(1, Z))

This will ensure that the inst variable for call to id/2 is bound in the way that is intended.
2018-03-06 15:31   
While investigating something else, I found that modecheck_higher_order_call calls inst_expand which does not look past a top-level node of constrained_inst_vars. So this does not work, but I think there is no reason it should not work.

:- inst b == (pred(in) is semidet).

:- pred p2(pred(int)::in(I)) is semidet <= I =< b.

p2(X) :- X(42).
2018-03-06 15:45   
The compiler crashes on create_test_unification.m:

Software Error: predicate `parse_tree.prog_mode.get_arg_insts'/4: Unexpected: defined_inst

simplify_goal_switch.create_test_unification calls inst_expand (which does not touch an inst with constrained_inst_vars at the top level) followed by get_arg_insts (which expects the inst to be expanded).

Issue History
2014-09-05 17:31wangpNew Issue
2014-09-05 17:31wangpFile Added: lambda.m
2014-10-09 11:44wangpNote Added: 0000793
2015-07-15 11:37markNote Added: 0000843
2018-03-06 15:24wangpFile Added: ho_constrained_poly_inst.m
2018-03-06 15:31wangpNote Added: 0000966
2018-03-06 15:41wangpFile Added: create_test_unification.m
2018-03-06 15:45wangpNote Added: 0000967