Files
mercury/tests/invalid/circ_inst5.m
Zoltan Somogyi cfe6782dd2 Improve diagnostics for circular insts and modes.
compiler/add_mode.m:
    Improve diagnostics for circular insts and modes in several ways.

    - Generate one error message per cycle, not one error message per inst.
      In the case of cycles containing more than one inst or mode, this
      reduces clutter.

    - Unlike the old code, we do print a context for every inst or mode
      in a cycle, rather than just for the first.

    - Avoid module qualifying local inst and mode names unless that
      qualification actually avoids ambiguity.

    - Use more expansive wording that actually explains *why* a circular
      inst or mode is a problem.

tests/invalid/circ_inst5.m:
    Extend this test case to test corner cases of the new code.

tests/invalid/circ_inst.err_exp:
tests/invalid/circ_inst2.err_exp:
tests/invalid/circ_inst3.err_exp:
tests/invalid/circ_inst4.err_exp:
tests/invalid/circ_inst5.err_exp:
tests/invalid/circ_mode.err_exp:
tests/invalid/circ_mode2.err_exp:
tests/invalid/circ_mode3.err_exp:
tests/invalid/circ_mode4.err_exp:
    Expect the updated error messages.
2021-10-16 12:14:49 +11:00

36 lines
875 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
:- module circ_inst5.
:- interface.
:- inst c == c(ground).
:- inst c(I) == i(c(I)).
:- inst i(I) == I.
:- type foo
---> foo.
:- func f(foo) = int.
:- mode f(in(c)) = out is det.
% Test that the error message
% - does not module qualify g2, g3, g4 and g5, since they are local only, but
% - does module qualify dead, since it also exists in builtin.m.
:- inst dead == g2.
:- inst g2 == g3.
:- inst g3 == g4.
:- inst g4 == g5.
:- inst g5 == circ_inst5.dead.
% Test that we report the circularity as involving only f2 and f3, and not f1,
% even though f1 has an infinite expansion as well.
:- inst f1 == f2.
:- inst f2 == f3.
:- inst f3 == f2.
:- implementation.
f(foo) = 1.