Files
mercury/tests/hard_coded/exist_cons_ho_arg.m
Zoltan Somogyi 03d6c5f436 Get higher insts from types as well as modes.
compiler/modecheck_call.m:
    As above. This fixes Mantis bug #529.

compiler/options.m:
    Allow configure to test whether the bug is fixed, so we can delete
    any now-redundant explicit higher order insts in mode declarations.

tests/hard_coded/exist_cons_ho_arg.{m,exp}:
    A test case for the bug. This is a strengthened version of the
    Mantis test case.

tests/hard_coded/Mmakefile:
    Enable the new test case.
2021-02-24 19:57:37 +11:00

70 lines
1.7 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% This test case checks whether the mode checker can get higher-order inst
% info out of types, such as the type of the second argument of the command
% function symbol below, when they are not specified as parts of modes.
%
:- module exist_cons_ho_arg.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
%---------------------------------------------------------------------------%
:- implementation.
:- import_module int.
:- import_module string.
main(!IO) :-
test_foo(!IO),
test_bar(!IO).
%---------------------------------------------------------------------------%
:- type command
---> some [T] command(T, pred(T::in, T::out) is det).
:- pred test_foo(io::di, io::uo) is det.
test_foo(!IO) :-
Command = foo_command,
Command = command(X, Pred),
Pred(X, Y),
io.write_line(Y, !IO).
:- pred test_bar(io::di, io::uo) is det.
test_bar(!IO) :-
Command = bar_command,
Command = command(X, Pred),
Pred(X, Y),
io.write_line(Y, !IO).
%---------------------------------------------------------------------------%
:- pred foo_pred(int::in, int::out) is det.
foo_pred(N, N + 1).
:- func foo_command = command.
foo_command = 'new command'(41, foo_pred).
%---------------------------------------------------------------------------%
:- pred bar_pred(string::in, string::out) is det.
bar_pred(S, S ++ S ++ S).
:- func bar_command = command.
bar_command = 'new command'("abc", bar_pred).
%---------------------------------------------------------------------------%