mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 19:03:45 +00:00
compiler/hlds_module.m:
compiler/prog_item.m:
Record the identity of predicates and functions that have misplaced
attempts at definition in the interface section using the
pred_pf_name_arity type instead of the pf_sym_name_arity type.
They both specify an arity, but only in pred_pf_name_arity is it clear
*which kind* of arity this is.
compiler/convert_parse_tree.m:
Record external declarations and foreign_procs in the interface
as misplaced attempts at predicate or function definition using
pred_pf_name_arity, so that the code obviously has no arity bugs,
whereas the old code merely had no obvious bugs. (It did actually work.)
Record fact_table pragmas in the interface as similar misplaced attempts
as predicate or function definition, *if* the pragma contains
a pred_or_func indication.
Factor out some common code.
compiler/hlds_pred.m:
Add predicates to return a pred_info's arity as pred_form_arity
and as user_arity.
compiler/make_hlds_separate_items.m:
compiler/typecheck_errors.m:
Conform to the changes above.
tests/invalid_nodepend/external_in_interface.{m,err_exp}:
tests/invalid_nodepend/foreign_proc_in_interface.{m,err_exp}:
tests/invalid_nodepend/fact_table_in_interface.{m,err_exp}:
Three new test cases to test the
tests/invalid_nodepend/Mmakefile:
Enable the new tests.
tests/invalid/external2.m:
Fix typo in comment.
39 lines
1.1 KiB
Mathematica
39 lines
1.1 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This module tests the effect of the presence of misplaced foreign_proc
|
|
% pragmas in the interface on error messages about missing clauses
|
|
% for the named predicates and/or functions.
|
|
%
|
|
|
|
:- module foreign_proc_in_interface.
|
|
|
|
:- interface.
|
|
|
|
:- pred foo(int::in, int::out) is det.
|
|
:- func foo(int) = int.
|
|
:- pred bar(int::in, int::out) is det.
|
|
:- func bar(int) = int.
|
|
|
|
:- pragma foreign_proc("C",
|
|
foo(In::in, Out::out),
|
|
[will_not_call_mercury, promise_pure, thread_safe],
|
|
"
|
|
Out = In;
|
|
").
|
|
|
|
:- pragma foreign_proc("C",
|
|
bar(In::in) = (Out::out),
|
|
[will_not_call_mercury, promise_pure, thread_safe],
|
|
"
|
|
Out = In;
|
|
").
|
|
|
|
:- implementation.
|
|
|
|
% No definition of pred foo/2, but there is a misplaced foreign_proc above.
|
|
% No definition of func foo/1. Should get an error message.
|
|
% No definition of pred bar/2. Should get an error message.
|
|
% No definition of func bar/1, but there is a misplaced foreign_proc above.
|