mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 19:33:46 +00:00
083d376e6598628362ee91c2da170febd83590f4
6 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3a1ed2efcb |
Replace simple_call_id with pf_sym_name_arity.
compiler/prog_data.m:
Delete the simple_call_id data type, since it is isomorphic
to the pf_sym_name_arity type, which more clearly specifies
what is stored inside it.
compiler/prog_out.m:
Rename (all three versions of) simple_call_id_to_string to
pf_sym_name_orig_arity_to_string, both to conform to the change
in the input data type, and to emphasize that the resulting string
will contain the *original* arity of functions (which does not include
the return value), which is one less than the arity in the
pf_sym_name_arity structure (which, in accordance with the
convention inside the compiler that the arity is the length
of the argument list, *does* include the return value).
Delete the provision inside simple_call_id_to_string, now
pf_sym_name_orig_arity_to_string, for special handling of the names
of the predicates we use to implement promises, because it seems that
*none* of the call sites to any of the three versions of this function
can actually pass to it the identity of such a predicate. These calls
refer to a predicate or mode declaration item (which promise predicates
do not have), to clause or foreign_proc items (which again, promise
predicates cannot have) or calls to the predicate (promise predicates
cannot be called).
Delete the exported predicate simple_call_id_to_sym_name_arity.
It was called from exactly one place, inside prog_out.m itself,
and this diff inlines that call.
Avoid unnecessary forwarding of work from prog_out.m to error_util.m.
Delete (all three versions of) write_simple_call_id. The changes
below replace all their (few) uses with calls to
pf_sym_name_orig_arity_to_string.
compiler/error_util.m:
Replace the simple_call() error piece with qual_pf_sym_name_orig_arity,
and add a new version unqual_pf_sym_name_orig_arity. Their names
explicitly say that they print the original arities of functions,
also say whether they strip away any module qualification on the
sym_name inside the pf_sym_name_arity. We prefer the unqual version
in situations where the module qualifier is implicit, which usually means
that it must be the same as the name of the module being compiled, because
it reduces visual clutter for readers of error messages.
Put {qual,unqual}_pf_sym_name_orig_arity next to their most closely
related function symbols, {qual,unqual}_sym_name_arity, in the
format_component type. (This yields a few inconsequential changes
in the order of error_specs when sorted.)
compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_proc.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/check_libgrades.m:
compiler/check_parse_tree_type_defns.m:
compiler/check_promise.m:
compiler/check_typeclass.m:
compiler/convert_parse_tree.m:
compiler/equiv_type.m:
compiler/goal_expr_to_goal.m:
compiler/hlds_data.m:
compiler/hlds_desc.m:
compiler/hlds_goal.m:
compiler/hlds_out_pred.m:
compiler/hlds_out_util.m:
compiler/hlds_pred.m:
compiler/inst_util.m:
compiler/llds_out_instr.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make_hlds_error.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/ml_unify_gen_construct.m:
compiler/mlds_to_c_stmt.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/modecheck_util.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_type_repn.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/pre_quantification.m:
compiler/pred_table.m:
compiler/prog_item.m:
compiler/recompilation.version.m:
compiler/term_constr_build.m:
compiler/termination.m:
compiler/type_ctor_info.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/typecheck_info.m:
compiler/unify_gen_construct.m:
compiler/unused_imports.m:
Conform to the changes above. Where I am pretty sure that in an error
message, the module qualifier of a name must be the current module,
use unqual_pf_sym_name_orig_arity instead of qual_pf_sym_name_orig_arity.
Add some sanity checks where they seem appropriate.
Replace sequences of io.write_strings with uses of io.format where this
yields clearer code. (This is why there were no remaining calls to
write_simple_call_id.)
Shorten some too-long lines.
In add_pred.m, make the order of some predicate definitions match
the order of the calls to them.
tests/invalid/ambiguous_method.err_exp:
tests/invalid/ambiguous_method_2.err_exp:
tests/invalid/bad_pred_arity.err_exp:
tests/invalid/bad_sv_unify_msg.err_exp:
tests/invalid/bigtest.err_exp:
tests/invalid/bug113.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/bug278.err_exp:
tests/invalid/bug410.err_exp:
tests/invalid/bug476.err_exp:
tests/invalid/bug487.err_exp:
tests/invalid/complex_constraint_err.err_exp:
tests/invalid/constrained_poly_insts.err_exp:
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/errors2.err_exp:
tests/invalid/exported_mode.err_exp:
tests/invalid/field_syntax_error.err_exp:
tests/invalid/foreign_singleton.err_exp:
tests/invalid/funcs_as_preds.err_exp:
tests/invalid/imported_mode.err_exp:
tests/invalid/invalid_binary_literal.err_exp:
tests/invalid/invalid_float_literal.err_exp:
tests/invalid/invalid_hex_literal.err_exp:
tests/invalid/invalid_octal_literal.err_exp:
tests/invalid/make_opt_error.err_exp:
tests/invalid/missing_det_decls.err_exp:
tests/invalid/multimode_syntax.err_exp:
tests/invalid/null_char.err_exp:
tests/invalid/occurs.err_exp:
tests/invalid/record_syntax_errors.err_exp:
tests/invalid/ref_to_implicit_pred.err_exp:
tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_1.err_exp2:
tests/invalid/require_tailrec_2.err_exp:
tests/invalid/require_tailrec_2.err_exp2:
tests/invalid/require_tailrec_3.err_exp:
tests/invalid/require_tailrec_3.err_exp2:
tests/invalid/state_vars_test2.err_exp:
tests/invalid/state_vars_test3.err_exp:
tests/invalid/state_vars_test5.err_exp:
tests/invalid/type_inf_loop.err_exp:
tests/invalid/typeclass_constraint_extra_var.err_exp:
tests/invalid/typeclass_mode_2.err_exp:
tests/invalid/typeclass_test_12.err_exp:
tests/invalid/typeclass_test_2.err_exp:
tests/invalid/typeclass_test_9.err_exp:
tests/invalid/types.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/unbound_type_vars.err_exp:
tests/invalid/with_type.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
tests/warnings/double_underscore.exp:
tests/warnings/pragma_source_file.exp:
tests/warnings/singleton_test.exp:
tests/warnings/singleton_test.exp2:
tests/warnings/singleton_test.exp3:
tests/warnings/singleton_test.exp4:
tests/warnings/singleton_test_state_var.exp:
tests/warnings/warn_return.exp:
tests/warnings/warn_return.exp2:
tests/warnings/warn_return.exp3:
tests/warnings/warn_succ_ind.exp:
tests/warnings/warn_succ_ind.exp2:
tests/warnings/warn_succ_ind.exp3:
tests/warnings/warn_succ_ind.exp4:
Update all these expected output files. Most changes are due to
predicate and function names no longer being module qualified when
the module qualification is obvious. A few changes are due to the
change in the relative ordering of the function symbols of the
format_component type.
For singleton_test, warn_return and warn_succ_ind in warnings,
the changes to the non-C .exp files were done by hand, so they
may have the wrong white space.
|
||
|
|
23c19ba5a5 |
Don't complain about missing mode decls without a pred decl.
The error message about the missing pred decl should remind the programmer
about the missing mode declaration (or predmode declaration) as well.
compiler/hlds_pred.m:
Add a marker, marker_no_pred_decl, that says that the given predicate
had no explicit predicate declaration.
compiler/add_pred.m:
When creating an implicit predicate declaration, because there is no
explicit one for a predicate that nevertheless has clauses,
attach the new marker to the new predicate.
compiler/mode_errors.m:
When about to generate an error message for a missing mode declaration,
make the error message empty if the predicate has the new marker.
compiler/hlds_out_pred.m:
compiler/intermod.m:
compiler/table_gen.m:
Conform to the change to hlds_pred.m.
tests/invalid/bigtest.err_exp:
tests/invalid/bug410.err_exp:
tests/invalid/constrained_poly_insts.err_exp:
tests/invalid/ref_to_implicit_pred.err_exp:
tests/invalid/typeclass_mode_2.err_exp:
Don't expect error messages about missing mode declarations
for predicates whose pred declaration is also missing (or invalid).
|
||
|
|
fdd141bf77 |
Clean up the tests in the other test directories.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
|
||
|
|
6682cc0a44 |
Improve the wording of some error messages.
Use the word "corresponding" instead of "preceding" in error messages like:
Error: clause for predicate `foo'/0 without preceding `:- pred'
declaration.
The language imposes no ordering on declarations so there is no sense in which
the `:- pred' declaration has to precede the clause. This is doubly true for
`:- typeclass' and `:- instance' declarations, which may also occur in
different source files from each other.
compiler/make_hlds_error.m:
compiler/add_class.m:
Make the above change.
Delete a comment regarding this issue.
tests/invalid/*/.err_exp:
Update expected error outputs.
|
||
|
|
d5cdd701b1 |
Further consistency improvements for error and warning messages.
The two main changes in this commit are: (1) Use the error_util library's decl/1 and pramga_decl/1 format components in more places. (2) Quote type variables that appear in error messages. compiler/error_util.m: Add a version of list_to_pieces/1 that places each of the strings in the input list in single quotes. compiler/prog_io_type_defn.m: Quote type variables names in error messages. compiler/add_class.m: compiler/add_pragma.m: compiler/add_pred.m: compiler/check_typeclass.m: compiler/make_hlds_error.m: compiler/post_typecheck.m: compiler/prog_io.m: Use the error_util library's decl/1 and pragma_decl/1 format components in more places. compiler/mode_errors.m: Quote program variables and insts in some error messages. compiler/post_term_analysis.m: Format a type ctor and arity in an error message properly. tests/invalid/*.err_exp: tests/warnings/*.exp: Conform to the above changes. |
||
|
|
91ce3a67a2 |
Avoid a compiler abort when people put a period in the middle of a clause.
The abort was caused by the fact that when the parser found an item that
looks like a fact for an undeclared predicate, such as the predicate ','/,
it created a hlds_pred filled with a clause_info in which terms that the
user intended to be goals are instead taken to be terms. Any reference
to predicates in those terms are taken by purity-checking to be higher order
references, which need a mode declaration. If the reference is to a predicate
(such as ,/2) whose declaration is implicit, that mode declaration will be
missing.
The fix has two parts. First, do not generate an abort in purity checking
when finding the mode declaration of a predicate or function in (what seems to
be) a higher order term is missing. Second, do not generate implicit
declarations for ,/2, since this is NEVER what the user wants.
A third part of this diff is an improvement in the contexts we record
for terms, for better error messages. I noticed the need for this when
looking at the compiler's output for the new cases.
compiler/post_typecheck.m:
When finding an apparent reference to a predicate or function with
no mode declarations, do not abort; instead, report an error.
compiler/purity.m:
Record the error reported by post_typecheck.m.
compiler/add_clause.m:
If we see a clause for `,'/2, do NOT treat it as implicitly defining
a ,/2 predicate. Instead, generate a situation-specific error message that
mentions the usual cause of the error.
compiler/add_pred.m:
Clean up the predicates that add the implicit predicate declarations
by making them both update module_infos, and by putting their arguments
into a consistent order.
compiler/make_hlds_passes.m:
Do likewise for a couple of predicates here.
compiler/add_pragma.m:
Conform to the change to add_pred.m.
compiler/superhomogeneous.m:
When expanding a term such as
line 1: p(a,
line 2: p(b,
line 3: c))
associate line 2 with the unification of a fresh variable with b,
and line 3 with the unification of a fresh variable with c. We used
to use the context of the top level term, which in this case is line 1,
instead.
This makes the compiler generate better (less misleading) output for the
ref_to_implicit_pred.m test case below, as well as in many other cases.
compiler/state_var.m:
When replacing !.X or !:X with a fresh variable term, copy the context
of the original functor term to the new variable term. Before the change
to superhomogeneous.m, this wasn't needed since the context of that term
was ignored, but now we use it.
tests/invalid/ref_to_implicit_pred.{m,err_exp}:
New test case to test the first part of the fix.
tests/invalid/ref_to_implicit_comma.{m,err_exp}:
New test case to test the second part of the fix.
tests/invalid/Mmakefile:
Enable both new test cases.
tests/hard_coded/impl_def_literal.{m,exp}:
Update this expected output for the more accurate contexts we now
generate, and update the comment in the source code accordingly.
tests/invalid/ambiguous_overloading_error.exp:
tests/invalid/max_error_line_width.err_exp:
tests/invalid/transitive_import_class.err_exp:
tests/warnings/ambiguous_overloading.exp:
Update these expected outputs for the more accurate contexts we now
generate.
|