Mercury Bugs - mercury
View Issue Details
0000526mercuryBugpublic2020-11-11 11:342021-04-28 11:17
Assigned Towangp 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000526: unused imports affected by opt-imported typeclass instances
DescriptionSome basic investigation of why warnings/bug412.m fails when intermodule optimisation is enabled.

The `io' module is considered used because polymorphism adds a typeclass info to the constant structure database due to opt-imported typeclass instances. Then const_struct_used_modules treats every constant structure as a use:

const_struct_used_modules(_ConstNum - ConstStruct, !UsedModules) :-
    % Every const_struct in the const_struct_db was put there because
    % it is used in module. None of the uses can be in the interface.
TagsNo tags attached.
Attached Files

2020-11-12 03:13   
The obvious fix is to add a field to each entry to the const_struct_db
that says "does this entry come from the current module, or not?",
and then ignore the fields with "no" answers when it comes to computing
the set of used modules. The only nontrivial aspect I see is when
two or more const structs use a smaller const struct; the smaller
const struct should say "for this module" if any of its users also say so.

Do you see anything wrong with this approach?
2020-11-30 13:35   
I think your approach should work.

(Sorry for the late response; the notification was caught by GMail's spam filter.)
2021-04-28 11:17   
Fixed by zs on 2021-01-23

Issue History
2020-11-11 11:34wangpNew Issue
2020-11-12 03:13zsNote Added: 0001124
2020-11-30 13:35wangpNote Added: 0001125
2021-04-28 11:17wangpAssigned To => wangp
2021-04-28 11:17wangpStatusnew => resolved
2021-04-28 11:17wangpResolutionopen => fixed
2021-04-28 11:17wangpNote Added: 0001134