mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 11:54:02 +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.
33 lines
1.2 KiB
Mathematica
33 lines
1.2 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This module tests the effect of the presence of misplaced fact_table
|
|
% pragmas in the interface on error messages about missing clauses
|
|
% for the named predicates and/or functions.
|
|
%
|
|
|
|
:- module fact_table_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.
|
|
:- pred baz(int::in, int::out) is det.
|
|
:- func baz(int, int) = int.
|
|
|
|
:- pragma fact_table(pred(foo/2), "nonexistent_foo").
|
|
:- pragma fact_table(func(bar/1), "nonexistent_bar").
|
|
:- pragma fact_table(baz/2, "nonexistent_baz"). % Ambiguity error.
|
|
|
|
:- implementation.
|
|
|
|
% No definition of pred foo/2, but there is a misplaced fact_table 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 fact_table above.
|
|
% No definition of pred baz/2. Should get an error message.
|
|
% No definition of func baz/2. Should get an error message.
|