Files
mercury/tests/invalid/bug257.m
Zoltan Somogyi 502ea379e4 Make require_complete_switch [X] require a switch on X.
compiler/det_report.m:
    Generate an error message if a require_complete_switch [X] scope
    is wrapped around a goal that is not a switch on X.

doc/reference_manual.texi:
    Update the reference manual to document this change. Also fix an
    old documentation problem: require_complete_switch scopes do NOT
    require covering all the function symbols in the type of the
    switch-on variable if the switched-on variable's inst says that
    it cannot be bound to some of them.

compiler/hlds_goal.m:
    Update the comment on the require_complete_switch scope
    in the same way.

NEWS:
    Announce the change.

tests/warnings/bug257.{m,exp}:
tests/invalid/bug257.{m,err_exp}:
tests/warnings/Mmakefile:
tests/invalid/Mmakefile:
    For the bug257.m test case, which has a require_complete_switch [X] scope
    around a goal that is not a switch on X, expect the error message
    we now generate, not the old warning.

    Since the compilation of bug257.m now fails, move it from warnings
    to invalid.

tests/valid/Mmakefile:
    Disable the bug257b.m test case, which also had a
    require_complete_switch [X] scope around a goal that was not a switch on X.

tests/valid/bug257b.m:
    Document that this test case is now disabled, and why.
2016-04-19 18:05:39 +10:00

27 lines
638 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% Regression test for bug #257: the compiler was not issuing a warning about
% the fact that the variable Gee which was the subject of a
% require_complete_switch did not occur in the scoped goal.
:- module bug257.
:- interface.
:- type xyz ---> x ; y ; z.
:- pred oops(xyz::in, int::out) is semidet.
:- implementation.
oops(G, N) :-
require_complete_switch [Gee]
(
G = x,
N = 1
;
G = y,
fail
).