Files
mercury/tests/invalid/switch_arm_multi_not_det.m
Zoltan Somogyi 590b34cfac Fix some minor problems in reporting determinism errors.
compiler/det_report.m:
    When a goal has too many solutions, but it occurs in a context in which
    the identity of those solutions does not matter, the compiler inserts
    a commit scope to prune away the redundant (because they are externally
    indistinguishable) solutions.

    When this goal is a switch inside a require_switch_arms_<detism> scope,
    this commit scope added by determinism analysis screwed up the expectation
    of the require_switch_arms_<detism> scope that the switch is its IMMEDIATE
    subgoal. Relax this sometimes-wrong assumption by allowing for a commit
    scope wrapped around the switch.

    When generating error messages for cons_ids missing from switches,
    don't print the module qualifiers for the cons_ids, since users
    will already know it (it is part of the identity of the type of switch-on
    variable).

    Print the missing cons_ids one per line, to make the list easier to read.

    Fix capitalization in some error messages.

compiler/switch_detection.m:
    When creating switch arms, give each arm a more meaningful context
    that the context of the original disjunction, which is usually the context
    of the first ";" operator in it.

tests/invalid/switch_arm_multi_not_det.{m,err_exp}:
    New test case for the fix listed first for det_report.m.

tests/invalid/Mmakefile:
    Enable the new test case.

tests/debugger/dice.exp*:
tests/invalid/det_errors.err_exp:
tests/invalid/require_scopes.err_exp:
    Update these expected outputs for the changes above.
2016-05-13 05:48:47 +10:00

39 lines
1.0 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%---------------------------------------------------------------------------%
%
% This is a regression test. Versions of the compiler before 2016 may 13
% did not generate an error message for the violation of the requirement
% imposed by the require_switch_arms_detism scope below, because the error
% it was meant to detect imposed a commit scope between the
% require_switch_arms_det scope and the switch itself.
:- module switch_arm_multi_not_det.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
( if test_switch_arms("c") then
io.write_string("Success\n", !IO)
else
io.write_string("Failure\n", !IO)
).
:- pred test_switch_arms(string::in) is semidet.
test_switch_arms(Name) :-
require_switch_arms_det [Name]
( Name = "a"
; Name = "b"
; Name = "c"
; Name = "c"
; Name = "d"
; Name = "d"
).