Mercury Bugs - mercury
View Issue Details
0000026mercuryBugpublic2007-11-12 12:482008-09-03 16:11
Reporterwangp 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000026: problem with inst for abstract type
DescriptionI'm not sure if this code should even be allowed, but the compiler aborts with the message:
Software Error: code_gen.m: Unexpected: semidet model in det context


The problem is something like this.
In rdfDiffStore.iterate_search there is a switch on WrappedStore. Simplification prunes the switch cases which it knows won't be taken due to the inst of WrappedStore. When the types rdfStore.open and rdfStore.transact are abstract, the instmap entry for WrappedStore says that it is bound to either unqualified(open) or unqualified(transact). These don't match rdfStore.open and rdfStore.transact, so all the switch cases are deleted, turning it into a `fail'.

When rdfStore.open and rdfStore.transact are non-abstract, then the instmap entry for WrappedStore are properly module qualified so the switch is not incorrectly pruned.
TagsNo tags attached.
Attached Files? rdfDiffStore.m (1,692) 2007-11-12 12:48
https://bugs.mercurylang.org/file_download.php?file_id=18&type=bug
? rdfStore.m (1,726) 2007-11-12 12:49
https://bugs.mercurylang.org/file_download.php?file_id=19&type=bug

Notes
(0000049)
juliensf   
2007-11-12 17:39   
It isn't clear to me what the correct thing to do here is.

If we had abstract insts then this sort of code shouldn't be allowed,
but as it is the relationship between abstract types and exported insts is
a bit fuzzy (to say the least).

It may be possible to tweak module qualification to allow this to "work",
but I think a proper fix for it is going to have to wait until the mode
analyser is redone.
(0000050)
juliensf   
2007-11-13 13:44   
The reason it doesn't work is that the body of the abstract type
is not included in the interface files. The importing module,
rdfDiffStore, therefore cannot qualify the inst properly.

Note, that this example will work with --intermodule-optimization enabled
(because the bodies of the abstract types are included in the optimization
interfaces.)
(0000111)
wangp   
2008-08-05 13:18   
The same problem has struck again. What to do to prevent this? Issue an error for abstract types with exported insts? Even if we might support it in the future, it's not supported *now*.
(0000112)
juliensf   
2008-08-05 13:24   
If it is causing problems then issuing some sort of warning would be a good idea.
I'm not sure how easy that would be to implement though.
(0000125)
wangp   
2008-08-08 15:14   
Added a warning about it, although it won't necessarily be issued in
time to stop confusing the user (the warning code isn't run when making
.int files).
(0000146)
wangp   
2008-09-03 16:11   
Sort of fixed.

Issue History
2007-11-12 12:48wangpNew Issue
2007-11-12 12:48wangpFile Added: rdfDiffStore.m
2007-11-12 12:49wangpFile Added: rdfStore.m
2007-11-12 17:39juliensfNote Added: 0000049
2007-11-12 17:39juliensfStatusnew => feedback
2007-11-13 13:44juliensfNote Added: 0000050
2008-08-05 13:18wangpNote Added: 0000111
2008-08-05 13:24juliensfNote Added: 0000112
2008-08-08 15:14wangpNote Added: 0000125
2008-09-03 16:11wangpStatusfeedback => closed
2008-09-03 16:11wangpNote Added: 0000146
2008-09-03 16:11wangpResolutionopen => fixed