Files
mercury/tests/invalid/abstract_eqv2.m
Peter Wang 366f94a73b Fix abstract equivalence types regression.
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.
2017-08-22 10:36:12 +10:00

20 lines
376 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
:- module abstract_eqv2.
:- interface.
:- type foo.
:- type bar
---> bar(int).
:- pred call_with_foo(foo::in) is det.
:- implementation.
:- type foo == bar.
call_with_foo(_).