Files
mercury/tests/valid/intermod_test.m
Andrew Bromage 04125e10ba Fix a bug in the writing of .opt files.
Estimated hours taken: 1

Fix a bug in the writing of .opt files.

The problem occurs when you have a pragma inline declaration for an
exported function.  The declaration:

:- func addone(int) = int.
:- pragma inline(addone/1).
addone(I) = I + 1.

gets written to the .opt file as:

:- pragma inline((foo:addone)/2).

That is, the arity of the _predicate_ version is written rather than
the arity of the _function_.

compiler/intermod.m:
compiler/mercury_to_mercury.m:
	Add a pred_or_func argument to mercury_output_pragma_decl,
	and use that to determine the declared arity.

tests/valid/intermod_test.m:
tests/valid/intermod_test2.m:
	Regression test.
1997-11-21 00:38:57 +00:00

35 lines
615 B
Mathematica

% Test overloading resolution for cross-module optimization.
:- module intermod_test.
:- interface.
:- import_module int.
:- pred p(int::out) is det.
:- type t
---> f(int)
; g.
:- implementation.
:- import_module intermod_test2.
p(X) :-
Y = f(1),
Y = f(_),
Lambda = lambda([Z::int_mode] is det, Z = 2),
local(Lambda, X).
:- mode int_mode :: out.
:- pred local(pred(int), int).
:- mode local(pred(int_mode) is det, out) is det.
local(Pred, Int) :- call(Pred, Int).
:- pred local_2(pred(int), int).
:- mode local_2(pred(int_mode) is det, out) is det.
local_2(Pred, plusone(Int)) :- call(Pred, Int).