mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 10:53:40 +00:00
The code that takes the function out of the term can use the function
as if it had the default signature. If it doesn't, this can lead to
This fixes Mantis bug 264.
compiler/mode_errors.m:
Provide a way to record such errors, and to print error messages for them.
compiler/modecheck_unify.m:
Look for such errors when constructing terms.
browser/declarative_user.m:
Don't put a function with a nondefault signature (it used a subtype)
into a term. Enforce the subtype with a runtime assertion instead.
doc/reference_manual.texi:
Document the new limitation.
tests/invalid/default_ho_inst.{m,err_exp}:
The test case for Mantis bug 264.
tests/invalid/Mmakefile:
Enable the new test case.
tests/valid/Mmakefile:
Disable the old ho_func_call test case, since it RELIES on putting
functions with nondefault modes into terms. It also uses I/O states
in ui modes.
29 lines
632 B
Mathematica
29 lines
632 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module default_ho_inst.
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- type foo
|
|
---> foo(func(string) = string).
|
|
|
|
:- pred callfoo(foo::in, string::in, string::out) is det.
|
|
|
|
callfoo(foo(F), X, F(X)).
|
|
|
|
:- func semifoo(string::in) = (string::out) is semidet.
|
|
|
|
semifoo(X) = X :- semidet_true.
|
|
|
|
main(!IO) :-
|
|
callfoo(foo(semifoo), "X", X),
|
|
io.write_string(X, !IO),
|
|
io.nl(!IO).
|