mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-21 12:23:44 +00:00
Fix Mantis bug 411. When an abstract type that is defined as equivalent
to another type is imported into another module, the other module would
see through the equivalence, making the abstract type not abstract at all.
The regression was introduced in commit 2856408ab0
"Separate the different kinds of sections in aug_comp_units."
-build_eqv_maps_in_blocks([], !TypeEqvMap, !InstEqvMap).
-build_eqv_maps_in_blocks([AugItemBlock | AugItemBlocks],
+build_eqv_maps_in_item_blocks([], !TypeEqvMap, !InstEqvMap).
+build_eqv_maps_in_item_blocks([ItemBlock | ItemBlocks],
!TypeEqvMap, !InstEqvMap) :-
- AugItemBlock = item_block(AugSection, _, Items),
- ( if AugSection = ams_abstract_imported(_) then
- true
- else
- build_eqv_maps_in_items(Items, !TypeEqvMap, !InstEqvMap)
- ),
- build_eqv_maps_in_blocks(AugItemBlocks, !TypeEqvMap, !InstEqvMap).
+ ItemBlock = item_block(_Section, _, Items),
+ build_eqv_maps_in_items(Items, !TypeEqvMap, !InstEqvMap),
+ build_eqv_maps_in_item_blocks(ItemBlocks, !TypeEqvMap, !InstEqvMap).
Before the change, items in an abstract-imported item block did not
contribute to the type equivalence maps. After the change, they would,
so abstract types would be replaced by their equivalent types.
Similarly for insts.
compiler/equiv_type.m:
Filter out abstract-imported item blocks from when building the type
and inst equivalence maps.
tests/invalid/Mmakefile:
tests/invalid/abstract_eqv.err_exp:
tests/invalid/abstract_eqv.m:
tests/invalid/abstract_eqv2.m:
Add test case.
20 lines
473 B
Mathematica
20 lines
473 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% Mantis bug 411. abstract_eqv.m should not be able to see that
|
|
% abstract_eqv2.m has *privately* defined foo to be equivalent to bar.
|
|
|
|
:- module abstract_eqv.
|
|
|
|
:- interface.
|
|
|
|
:- pred bad is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module abstract_eqv2.
|
|
|
|
bad :-
|
|
call_with_foo(bar(1)).
|