Mercury Bugs - mercury
View Issue Details
0000191mercuryBugpublic2011-03-22 13:522015-11-02 11:10
Assigned Tojuliensf 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000191: indirect instance implementations ignore special insts
DescriptionIf a typeclass requires a predicate of a specific inst, but an instance indirectly defines that predicate (using "is"), the inst is not properly checked and an implementation with a more general inst (e.g. in or out) can be used. Result is a software error during compile, below.
Additional InformationSoftware Error: code_gen.m: Unexpected: semidet model in det context
TagsNo tags attached.
Attached Files? instbug.m (507) 2011-03-22 13:52
patch inst_match.patch (526) 2011-04-05 12:21
patch inst_match2.patch (14,424) 2011-04-07 13:37

2011-03-22 14:18   
(Last edited: 2011-03-22 14:25)
This seems to be part of a more general problem of complex insts not being propagated through predicate calls. Am I misunderstanding the semantics of the language?

Edit: seems to be related to bugs # 86 and 117.

2011-04-05 12:22   
Squashed it, was a one-line fix in compiler/inst_match.m. Also fixes bugs 86 and 117. See attached patch.
2011-04-07 03:22   
The above patch breaks compilation of the stage 2 standard library. (That doesn't necessarily
mean it is incorrect, since at least some the library code that breaks looks suspicious -- we
will need to look into this further before applying the above patch.)
2011-04-07 13:41   
That's what I get for being sneaky and skipping the install phase :)

Attached is a (much larger) patch that fixes *most* of the library issues. It involved some mode additions to the list module (there really should be lots more), generalizing the mode of cc_multi_equal, and specializing cc_multi_equal in exception.m (this is due to the fact that the compiler chooses the di/uo mode of cc_multi_equal as "best" and doesn't try the other mode when it fails).

term_to_xml.m still doesn't compile, and I believe it is due to a possible bug I mentioned on the users mailing list, concerning predicates which refine nested insts. The error I'm getting is:

term_to_xml.m:1348: In clause for `'__Unify__'(in, (unique(list.'[|]'(free,
term_to_xml.m:1348: unique((list.[])))) >> bound(list.'[|]'(ground,
term_to_xml.m:1348: bound((list.[]))))), (ground >>
term_to_xml.m:1348: bound((list.[]))))))':
term_to_xml.m:1348: mode error: argument 3 did not get sufficiently
term_to_xml.m:1348: instantiated.
term_to_xml.m:1348: Final instantiatedness of `HeadVar__2' was
term_to_xml.m:1348: `bound(list.'[|]'(ground, ground))',
term_to_xml.m:1348: expected final instantiatedness was
term_to_xml.m:1348: `bound(list.'[|]'(ground, bound((list.[]))))'.

which looks suspiciously similar to the issue I mentioned. I will focus my efforts on trying to track down that bug, and will hope that it's as simple as this one was to fix.
2015-11-02 11:10   
This was fixed in commit 491bb0a.

Issue History
2011-03-22 13:52colandermanNew Issue
2011-03-22 13:52colandermanFile Added: instbug.m
2011-03-22 14:18colandermanNote Added: 0000321
2011-03-22 14:25colandermanNote Edited: 0000321
2011-04-05 12:21colandermanFile Added: inst_match.patch
2011-04-05 12:22colandermanNote Added: 0000322
2011-04-07 03:22juliensfNote Added: 0000323
2011-04-07 13:37colandermanFile Added: inst_match2.patch
2011-04-07 13:41colandermanNote Added: 0000326
2015-11-02 11:10juliensfNote Added: 0000859
2015-11-02 11:10juliensfStatusnew => resolved
2015-11-02 11:10juliensfResolutionopen => fixed
2015-11-02 11:10juliensfAssigned To => juliensf