Files
mercury/tests/invalid/multimode_dcg.m
Zoltan Somogyi 24ec389860 Improve diagnostics about missing ::mode annotations.
compiler/add_clause.m:
    When a mode-specific clause is missing a ::mode annotation from some
    arguments, print the identities of those arguments.

compiler/add_pred.m:
    Improve the wording of a diagnostic.

tests/invalid/mode_decl_in_wrong_section.err_exp:
tests/invalid/multimode_dcg.err_exp:
tests/invalid/multimode_dcg.m:
tests/invalid/multimode_syntax.err_exp:
    Expect updated diagnostics.
2024-05-30 22:19:22 +10:00

53 lines
1.2 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
:- module multimode_dcg.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
main(!IO) :-
In = 42,
test0(!IO),
test1(In, !IO),
test1(_Out0, !IO),
test2(In, In, !IO),
test2(In, _Out1, !IO),
test2(_Out2, In, !IO),
test2(_Out3, _Out4, !IO).
:- pred test0(io, io).
:- mode test0(di, uo) is det.
test0 -->
puts("test0").
:- pred test1(int, io, io).
:- mode test1(in, di, uo) is det.
:- mode test1(out, di, uo) is det.
test1(_::in) -->
puts("test1(in)").
test1(0::out, In::in, Out) :-
puts("test1(out)", In, Out).
:- pred test2(int, int, io, io).
:- mode test2(in, in, di, uo) is det.
:- mode test2(in, out, di, uo) is det.
:- mode test2(out, in, di, uo) is det.
:- mode test2(out, out, di, uo) is det.
test2(_::in, _::in) -->
puts("test2(in, in)").
test2(_::in, 0::out) -->
puts("test2(in, out)").
test2(0::out, _::in) -->
puts("test2(out, in)").
test2(0::out, 0::out) -->
puts("test2(out, out)").
:- pred puts(string::in, io::di, io::uo) is det.
puts(S) -->
io.write_string(S), nl.