Commit Graph

23 Commits

Author SHA1 Message Date
Zoltan Somogyi
c03b11ca48 Update the style of more test cases.
And updated expected outputs for changed line numbers.
2021-07-27 19:29:21 +10:00
Zoltan Somogyi
6bfef65f50 Fix the reminder about hidden messages itself being hidden.
compiler/mercury_compile_main.m:
    When we generate more messages for the user than we show, either
    because of --limited-error-context options or because the user has
    not asked for the verbose part of messages, we used to print a reminder
    about this fact in only one case:

    - at the end of the compilation, and
    - only if the exit status wasn't zero.

    Both of these condition was wrong.

    - If we were compiling modules a, b, c, d ... z, we could get a message
      about more messages being available being printed after the compilation
      of a module (z) for which we generated *no* messages at all, just because
      some message earlier in the list got such messages.

    - If the compilation generated no errors but only warnings, then
      we never printed reminders about any verbose parts of those warnings
      being held back.

    Fix both of these issues by

    - separating the code doing the reminder into its own predicate,
      and invoking it at the end of the processing of each module
      (leaving a call at its old location where it is invoked
      after we have processed all modules), and

    - not making the invocation conditional on exit status.

tests/warnings/ambiguous_overloading.exp:
tests/warnings/arg_order_rearrangment.exp:
tests/warnings/bug477.exp:
tests/warnings/infinite_recursion.exp:
tests/warnings/simple_code.exp:
tests/warnings/singleton_test.exp:
tests/warnings/singleton_test.exp2:
tests/warnings/singleton_test.exp3:
tests/warnings/singleton_test.exp4:
    Update these to expect the "For more information, recompile with `-E'"
    message, now that we don't hide it.

tests/warnings/singleton_test.m:
    Document what the four .exp files are for.
2019-10-26 13:21:30 +11:00
Zoltan Somogyi
0584bc300d Expand obsolete pragmas with an optional "suggested replacements" field.
doc/reference_manual.texi:
NEWS:
    Document the extension.

compiler/prog_item.m:
    Add a field to the representation of obsolete pragmas to hold
    an optional list of suggested possible replacements.

compiler/parse_pragma.m:
    Parse the optional second argument in obsolete pragmas.

    Improve the error messages we generate for several kinds of errors
    we may encounter when parsing pragmas by making them more specific.

compiler/hlds_pred.m:
    Since an obsolete pragma now contains more than one bit of information
    (present vs not present), change their representation from a simple marker
    to a field containing the possible replacements.

    Make a comment about access stats more useful by sorting its contents
    on frequency of access, and putting it before the structure it is about.

compiler/simplify_goal_call.m:
    When generating warnings about calls to obsolete predicates or functions,
    mention the suggested replacements, if there are any.

compiler/add_pragma.m:
    Fill in the new field when adding an obsolete pragma to the HLDS.

compiler/globals.m:
    Add a function for use by new codee in parse_pragma.m.

compiler/canonicalize_interface.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/hlds_out_pred.m:
compiler/intermod.m:
compiler/item_util.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out_pragma.m:
compiler/prog_item_stats.m:
compiler/recompilation.version.m:
compiler/table_gen.m:
    Conform to the changes above.

tests/invalid/bad_foreign_code.err_exp:
tests/invalid/bad_foreign_enum.err_exp:
tests/invalid/bad_foreign_export.err_exp:
    Expect the improved error messages from parse_pragma.m.

tests/warnings/simple_code.{m,exp}:
    Add tests of the new forms of the obsolete pragma.
2019-09-09 13:53:21 +10:00
Zoltan Somogyi
7b893150de Include predicate names in warnings about infinite loops.
compiler/simplify_goal_call.m:
    As above.

    Also improve some comments, some predicate names, and formatting,
    as part of a post-commit review.

tests/invalid/loopcheck.err_exp:
tests/warnings/infinite_recursion.exp:
tests/warnings/simple_code.exp:
    Expect the predicate name in infinite loop warnings.

tests/tabling/Mercury.options:
tests/tabling/Mmakefile:
    Disable warning about the infinite loop this test case tests
    not by filtering out lines from the compiler output (which does not
    work anymore due to the predicate name causing the warning to spill
    onto a second line), but by simply asking the compiler not to generate
    the warning.

    Fix an old problem: the Mmakefile action for the loopcheck_nondet test case
    was modifying a file that did not belong to it.
2018-10-24 15:12:58 +11:00
Zoltan Somogyi
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.
2015-02-16 12:32:18 +11:00
Zoltan Somogyi
85da715041 Generate a specific warning for X = f(X).
This warning is for when X is ground. When X is free (or otherwise nonground),
such unifications have always gotten an error.

compiler/mode_errors.m:
    Add a warning type for occur check violations with ground vars.

    Fix the grammar in the other two warnings generated by mode analysis.

compiler/modecheck_unify.m:
    Generate the new warning when appropriate.

    To make this possible, rewrite a previously 280-line predicate
    that was hard to understand because of its structure as well as its
    length into a smaller, better structured predicate less than half the size
    (a) by moving coherent pieces of it out into other predicates,
    some of which are now called more than once, thus reducing code
    duplication, and (b) by avoiding redundant work, to wit, optimizing
    the form of a unification when we have already decided that it has
    a mode error, and thus cannot be scheduled now.

compiler/prog_mode.m:
    Add a det version of an existing predicate.

compiler/inst_util.m:
    Remove a comment on a predicate implementation that duplicates the
    comment on the predicate's declaration.

compiler/modecheck_util.m:
    Minor fixes of comments.

compiler/superhomogeneous.m:
    Fix some bit rot: update the name of a predicate to match
    the name of the data it works on, which was changed a few
    years ago.

tests/invalid/occurs.err_exp:
tests/invalid/qualified_cons_id2.err_exp:
tests/warning/simple_code.exp:
tests/warning/unify_f_g.exp:
    Conform to the error message format we generate after the change
    to mode_errors.m.

tests/warning/unify_x_f_x.{m,exp}:
    A new test case to test the new functionality.

tests/warning/Mmakefile:
    Enable the new test case.
2014-11-10 17:00:08 +11:00
Zoltan Somogyi
cc1711071e Make all the pre-HLDS and front-end passes of the compiler gather up
Estimated hours taken: 50
Branches: main

Make all the pre-HLDS and front-end passes of the compiler gather up
all their error messages and print them all at once, in sorted order,
unless the user asked for progress messages, in which case we print all the
errors accumulated so far just before each printing each progress message.

This should make error message output significantly easier to interpret.

compiler/module_imports.m:
	Add a new field to the module_imports structure (the main pre-HLDS
	representation of the parse tree) to hold the list of error messages
	generated so far.

	Rename the module_imports structure as the module_and_imports
	structure, since it holds the module's items as well as information
	about its imports.

	Update the access predicates to encourage getting the items, the error
	messages and the error indication all at once.

	Add mechanisms for updating the error indication and the error
	messages.

	Add a distinguishing prefix to the field names of the structure.

compiler/error_util.m:
compiler/hlds_error_util.m:
	Add facilities for printing error messages in batches.

	In error_util.m, delete an unused argument from several predicates.

compiler/mercury_compile.m:
compiler/intermod.m:
	Gather up error messages to print in batches.

	In the parts of the code affected by the above, explicitly pass
	around a globals structure, instead of having all the predicates
	get it of the I/O state. Since some code (e.g. the start recompilation
	system) still uses the copy in the I/O state, we ensure that this copy
	is kept in sync with the explicitly passed around copy.

	Rename some predicates to avoid ambiguities.

compiler/modules.m:
	Return errors in the module_and_imports structure, not separately.

	Gather up error messages to print in batches.

	Explicitly pass around globals structures.

compiler/read_modules.m:
	Rename the read_modules type to have_read_module_map, since this is
	more explicit.

	For each module we have already read, remember not just the items we
	read from it, but also the error messages we generated during the
	reading. This is so these error messages can be printed together with
	other errors from other sources.

	Explicitly pass around globals structures.

compiler/prog_io.m:
compiler/purity.m:
compiler/stratify.m:
	Rename several predicates to avoid ambiguities.

compiler/modes.m:
	Change the interface of the main predicate to avoid the need for a
	lambda expression in mercury_compile.m.

compiler/recompilation.check.m:
	Add a distinguishing prefix to the field names of a structure.

	Fix a wrong definition of this_file.

	Conform to the changes above.

compiler/compiler_target_code.m:
compiler/deps_map.m:
compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds.m:
compiler/make_hlds_passes.m:
compiler/trans_opt.m:
compiler/write_deps_file.m:
	Conform to the changes above.

compiler/add_clause.m:
compiler/add_pragma.m:
compiler/state_var.m:
	Add an import of io, since their parent make_hlds.m does not import io
	anymore.

	In add_pragma, update an error message that did not mention trseg as
	well as tr as indicating a trailing grade.

tests/hard_coded/Mmakefile:
	Move two tests that cannot pass in debug grades due to the lack of tail
	recursion to the list containing the other tests with this property.

tests/invalid/test_feature_set.err_exp:
	Update the expected output of this test to expect the updated error
	message from add_pragma.

tests/invalid/test_feature_set.err_exp2:
	Add this file as the expected output for trailing grades.

tests/invalid/*.err_exp:
tests/warnings/*.err_exp:
	Update the expected output for many tests to expect the error messages
	in sorted order.
2009-08-14 20:37:57 +00:00
Ian MacLarty
ac651b033b Only report mode warnings if they occur in all modes.
Estimated hours taken: 5
Branches: main

Only report mode warnings if they occur in all modes.
simplify.m already had code to remove error_specs that do not occur in all
modes, so move this code to error_util.m and reuse it in modes.m.

Also only report mode warnings for user defined predicates.  Do not report them
for compiler generated predicates (after making the change in the previous
paragraph, the compiler issued a warning for a generated unification predicate
in term_to_xml.m).

compiler/cse_detection.m:
	Conform to new interface of modecheck_proc.

compiler/error_util.m:
	Add an abstract type error_spec_accumulator and predicates for
	working with this type.  The new type is used for accumulating
	errors over multiple modes of a predicate.

	The code for accumulating error specs has been moved from simplify.m.
	There was a bug in this code caused by the arguments of the pair
	in the error_spec_accumulator type getting mixed up.  This bug has now
	been fixed.

	Add mode_report_control to the modecheck phase, so we can mark which
	error specs should only be reported if they occur in all modes.

compiler/mode_errors.m:
	Delete report_mode_errors and report_mode_warnings, since these are
	no longer used.

	Export mode_error_info_to_spec and mode_warning_info_to_spec for
	converting mode errors and warnings to error specs.

	Conform to changes in error_util.m.

compiler/modecheck_unify.m:
	Do not supress warnings if the mode may use a subtype, since we
	want such warnings to be displayed if the occur in all modes.

	Only report mode warnings if the predicate is not a compiler generated
	predicate.

compiler/modes.m:
	Delete modecheck_pred_mode and modecheck_proc_info, since they are
	not used anywhere.

	In modecheck_proc and modecheck_proc_general report a list of
	error specs, instead of the number of errors.  These predicates are
	now no longer responsible for printing the errors, they just return
	the error specs.  We need to do it this way so we can accumulate the
	errors over all modes (eliminating any warnings that don't occur in
	all modes) before printing them.

	Report errors in modecheck_pred_mode_2, after all modes have been
	processed.

	Accumulate the error specs in modecheck_procs, using the new predicates
	in error_util.m.

	Move the code for only reporting the first error encountered for a proc
	from mode_errors.m to here.  Also improve the comment for that bit of
	code.

	Conform to changes in error_util.m.

compiler/pd_util.m:
	Conform to changes in error_util.m.

compiler/simplify.m:
	Move the code for accumulating error specs to error_util.m

compiler/unify_proc.m:
compiler/unique_modes.m:
	Conform to changes elsewhere.

tests/invalid/ho_type_mode_bug.err_exp:
	The order the errors are reported has changed here, because we now
	call write_error_specs to report mode errors.

tests/invalid/qualified_cons_id2.err_exp:
tests/warnings/simple_code.exp:
tests/warnings/simple_code.m:
	We now correctly report a warning we didn't report before.
2007-05-28 01:06:25 +00:00
Zoltan Somogyi
5eee81204e A big step towards cleaning up the way we handle errors.
Estimated hours taken: 28
Branches: main

A big step towards cleaning up the way we handle errors. The main changes are

- the provision, in error_util.m, of a mechanism for completely specifying
  everything to do with a single error in one data structure,

- the conversion of typecheck_errors.m from using io.write_string to
  using this new capability,

- the conversion of mode_errors.m and det_report.m from using
  write_error_pieces to using this new capability, and

- consistently using the quoting style `symname'/N instead of `symname/N'
  in error_util and hlds_error_util (previously, error_util used the former
  but hlds_error_util used the latter).

This diff sets up later diffs which will collect all error specifications
in a central place and print them all at once, in order.

compiler/error_util.m:
	The new type error_spec, which completely specifies an error.
	An error_spec may have multiple components with different contexts
	and may have parts which are printed only under certain conditions,
	e.g. a given option being set. Each error_spec has a severity
	and also records which phase found the error.

	The new predicate write_error_spec takes care of updates of the exit
	status for errors and (if --halt-at-warn is set) for warnings. It also
	takes care of setting the flag that calls for the reminder about -E
	at the end.

	This diff also makes it simpler to use the ability to print arbitrary
	output. It adds the ability to include integers in messages directly,
	and the ability to create blank lines. It renames some function symbols
	to avoid ambiguities.

	Move a predicate that only used by typecheck_errors.m to that file.

compiler/hlds_error_util.m:
	Switch to the `symname'/N quoting style for describing predicates and
	procedures.

compiler/prog_util.m:
	Switch to the `symname'/N quoting style for describing
	sym_name_and_arity.

compiler/hlds_module.m:
	Provide a predicate to increment the number of errors not by one,
	but by the number of errors printed by write_error_spec.

	Fix some documentation rot.

compiler/typecheck_errors.m:
	Use write_error_spec instead of io.write_strings to print error
	messages. In several cases, improve the formatting of the messages
	printed.

	Mark a number of places where we don't (yet) update the number of
	errors in the module_info correctly.

	Rename the checkpoint predicate to avoid potential ambiguity with
	similar predicates in e.g. mode_info.

compiler/typecheck_info.m:
	Group the code for writing stuff out together in one bunch. For each
	such predicate, create another that returns a list of format components
	instead of doing I/O directly.

compiler/typecheck.m:
	Move the code for writing inference messages here from
	typecheck_errors.m, since these messages aren't errors.

compiler/mode_errors.m:
compiler/det_report.m:
	Use write_error_spec instead of write_error_pieces. In the case of
	mode_errors.m, this means we now get correct the set of circumstances
	in which we set the flag that calls for the reminder about -E.

compiler/add_pragma.m:
compiler/add_type.m:
	Convert some code that used to use write_error_pieces to print error
	messages to use write_error_spec instead.

compiler/assertion.m:
compiler/hlds_pred.m:
compiler/post_typecheck.m:
	Assertion.m used to contain some code to check for assertions in the
	interface that mention predicates that are not exported. Move most
	of this code to post_typecheck.m (which is where this code used to be
	called from). One small part, which is a test for a particular property
	of import_statuses, is moved to hlds_pred.m to be with all the other
	similar tests of import_statuses.

compiler/prog_util.m:
	Change unqualify_name from a predicate to a function.

compiler/pred_table.m:
compiler/hlds_out.m:
	Avoid some ambiguities by adding a suffix to the names of some
	predicates.

compiler/*.m:
	Conform to the changes above.

library/list.m:
	Add a function that was previously present (with different names)
	in two compiler modules.

tests/hard_coded/allow_stubs.exp:
	Update the format of the expected exception.

tests/invalid/errors2.err_exp2:
	Remove this file. As far as I can tell, it was never the correct
	expected output on the main branch. (It originated on the alias branch
	way back in the mists of time.)

tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/warnings/*.exp:
	Update the format of the expected error messages.

tests/recompilation/*.err_exp.2:
	Update the format of the expected messages about what was modified.
2006-09-07 05:51:48 +00:00
Zoltan Somogyi
b819fbc0a6 Give the compiler the capability of detecting errors that manifest themselves
Estimated hours taken: 16
Branches: main

Give the compiler the capability of detecting errors that manifest themselves
as mismatches between the format string and the list of values to be printed
in calls to string.format and io.format.

This capability is controlled through two new options:

	--warn-known-bad-format-calls
	--warn-unknown-format-calls

The first (which will default to "on" once this change has bootstrapped)
controls whether the compiler emits warnings for statically known mismatches.
The second (which will default to "off") controls whether the compiler emits
warnings in cases where either the format string or the structure of the list
of values to be printed is not available statically to be checked.

NEWS:
	Mention the new capability.

compiler/options.m:
	Add the two new options.

doc/user_guide.texi:
	Document the new options.

compiler/format_call.m:
	New module to implement the new capability.

compiler/notes/compiler_structure.html:
	Document the new module.

compiler/check_hlds.m:
	Include the new module.

compiler/simplify.m:
	Invoke the new module if the procedure being processed contains calls
	to string.format or io.format.

	Fix an old bug: we could generate warnings or even errors when
	simplifying predicate bodies imported from other modules via
	intermodule optimization.

	Don't export get/set predicates that do not need to be exported.

compiler/det_report.m:
	Add new kinds of error specifications for the errors detected by the
	new module.

	Separate out the context of each error specification, in order
	to allow the error messages to be sorted by context; this makes
	the output much easier to read.

compiler/common.m:
compiler/det_analysis.m:
compiler/simplify.m:
	Conform to the change to det_report.m.

mdbcomp/prim_data.m:
	Add a utility function for forming the possibly qualified names of
	library modules (such as "io" and "string").

library/Mercury.options:
compiler/Mercury.options:
	Add the lines that disable the new checks in the modules that need them
	disabled. The new lines are commented out until installed compilers all
	understand them, at which point in time we will add the requirement to
	understand the option to configure.in.

compiler/fact_table.m:
compiler/mlds_to_il.m:
	Fix three bugs reported by the new check that have apparently escaped
	detection all this time.

library/rtti_implementation.m:
	Change some code to avoid a spurious warning from the new checks.

library/string.m:
	Rename a predicate to avoid an unnecessary and confusing overloading of
	its name.

	Replace __ with . as module qualifier connective.

compiler/handle_options.m:
library/pprint.m:
	Misc cleanups.

tests/invalid/string_format_bad.{m,err_exp}:
tests/invalid/string_format_unknown.{m,err_exp}:
	New test cases to test the new warnings.

tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
	Enable the new test cases.

tests/general/string_format_test*.exp*:
	Update any expected abort messages to expect . instead of __ as module
	qualifier connective.

tests/invalid/det_errors_cc.err_exp:
tests/invalid/erroneous_throw_promise.err_exp:
tests/warnings/simple_code.exp:
	Expect the same error messages in program context order.
2006-01-27 05:52:27 +00:00
Zoltan Somogyi
2f06c5b8fe Don't just detect when successive unifications unify the same variable with
Estimated hours taken: 6
Branches: main

Don't just detect when successive unifications unify the same variable with
incompatible function symbols: also issue a warning.

compiler/ml_code_gen.m:
compiler/stratify.m:
compiler/table_gen.m:
mdbcomp/trace_counts.m:
	Fix pieces of code that get the new warning.

compiler/modecheck_unify.m:
	When detecting such unifications, add warnings for them, except if
	the initial inst of the current restricts the set of allowed bindings
	of the input arguments. If the initial inst of X is bound(f), then
	an otherwise correct unification Y = g may fail if Y has been computed
	from X. (We don't whether it has, so we have to be conservative.)
	There are examples of such code in the library, e.g. functor in
	deconstruct.m.

	Factor out some common code.

compiler/mode_errors.m:
	Add the infrastructure needed for printing warnings, and the two forms
	of this warning in particular.

compiler/mode_info.m:
	Extend the mode_info structure to make room for warnings, and for the
	initial inst of the procedure arguments.

	Switch to four-space indentation.

compiler/inst_util.m:
	Add a predicate that tests whether an inst may restrict the set of
	possible cons_ids a variable may be bound to.

	Change the argument order of some predicates to allow them to be
	used in higher order code. We don't need to make the switched-on
	argument the first argument anymore.

	Switch to four-space indentation.

compiler/hlds_goal.m:
	Change the argument order of some predicates to allow the use of state
	variables.

compiler/higher_order.m:
compiler/instmap.m:
compiler/mode_constraints.m:
compiler/mode_debug.m:
compiler/mode_ordering.m:
compiler/modecheck_call.m:
compiler/trace.m:
	Conform to the changed argument orders described above.

	Switch to four-space indentation.

compiler/common.m:
compiler/inst_match.m:
compiler/hlds_pred.m:
compiler/lambda.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/modes.m:
compiler/pd_util.m:
compiler/post_typecheck.m:
compiler/unique_modes.m:
	Conform to the changed argument orders described above.

tests/invalid/occurs.err_exp:
	Expect the extra warning.

tests/warnings/Mmakefile:
	Enable the unify_f_g test case I accidentally committed earlier.

tests/warnings/unify_f_g.{m,err_exp}:
	Finalize that test case.

tests/warnings/simple_code.err_exp:
	Expect the extra warning.
2005-08-27 09:42:10 +00:00
Zoltan Somogyi
9187c0d911 Bring these modules up to date with our current style guidelines.
Estimated hours taken: 8
Branches: main

compiler/hlds_out.m:
compiler/llds_out.m:
	Bring these modules up to date with our current style guidelines.
	Use state variables in the few places where we weren't doing so
	already.

compiler/purity.m:
	Bring this module up to date with our current style guidelines.
	Use the predicates of error_util and hlds_error_util to print error
	messages. Be more consistent in using quotations. Fix indentation.

compiler/error_util.m:
	Add a long needed facility: the ability to glue some punctuation
	at the end of a previous word.

	Add a mechanism for turning a list of components into a string,
	instead of printing them out.

	Make the interface of this module more consistent by making
	list_to_pieces a function just like component_lists_to_pieces.

compiler/hlds_error_util.m:
	Change the way we describe predicates and procedures. Instead of
	returning their descriptions as single fixed strings that error_util
	can't break up across lines, return them as separate components that
	can be split across lines. This makes error output look nicer.

	Fix a mismatch between what were supposed to be corresponding pieces
	of code in hlds_error_util and hlds_out.

	Turn the appropriate predicates into functions.

compiler/*.m:
	Conform to the changed interfaces of some of the above modules.

tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/recompilation/*.err_exp:
tests/warnings/*.exp:
	Update the expected outputs for the better looking error messages we
	now generate.
2005-01-17 05:01:48 +00:00
Zoltan Somogyi
bc56e927b6 Detect when a predicate has a pair of I/O states but isn't det or cc_multi.
Estimated hours taken: 6
Branches: main

Detect when a predicate has a pair of I/O states but isn't det or cc_multi.
Improve the generation of determinism error messages.

compiler/det_analysis.m:
	Detect when a predicate has a pair of I/O states but isn't det or
	cc_multi.

	Factor out some common code.

compiler/det_report.m:
	Add the new error type for predicates with I/O states.

	Use error_util much more extensively to generate error messages.

compiler/hlds_out.m:
	For several existing predicates that write out various HLDS
	constructs, provide versions that return representations of those
	constructs as strings or as error_util pieces, for use by det_report.m.
	Redefine the old predicates as simply printing the output of the new
	predicates where relevant, to avoid code duplication.

compiler/error_util.m:
	When describing a predicate name, specify whether we want to module
	qualify the name or not. The intention is that when generating a kind
	of error message which can only be generated for predicates defined
	in the current module, the module prefix should be omitted in the
	interest of clarity.

compiler/accumulator.m:
compiler/dead_proc_elim.m:
compiler/magic_util.m:
compiler/table_gen.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/typecheck.m:
	Conform to the changes in error_util.m.

compiler/globals.m:
	Reorder arguments to allow the use of state variable notation.

compiler/handle_globals.m:
compiler/mercury_compile.m:
compiler/source_file_map.m:
	Conform to the changed argument order in globals.m.

tests/invalid/aditi_update_errors.err_exp:
tests/invalid/errors2.err_exp2:
tests/invalid/external.err_exp:
tests/invalid/ho_unique_error.err_exp:
tests/invalid/magicbox.err_exp:
tests/invalid/missing_det_decls.err_exp:
tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
tests/invalid/multimode_syntax.err_exp:
tests/invalid/multisoln_func.err_exp:
tests/invalid/pragma_c_code_dup_var.err_exp:
tests/invalid/pragma_c_code_no_det.err_exp:
tests/invalid/prog_io_erroneous.err_exp2:
tests/invalid/qualified_cons_id2.err_exp:
tests/invalid/record_syntax_errors.err_exp:
tests/invalid/state_vars_test1.err_exp:
tests/invalid/state_vars_test2.err_exp:
tests/invalid/state_vars_test3.err_exp:
tests/invalid/typeclass_mode.err_exp:
tests/invalid/types.err_exp2:
tests/invalid/undef_mode_and_no_clauses.err_exp:
tests/recompilation/typeclass_method_pragma_r.err_exp.2:
tests/warnings/ambiguous_overloading.exp:
tests/warnings/duplicate_call.exp:
tests/warnings/duplicate_const.exp:
tests/warnings/infinite_recursion.exp:
tests/warnings/simple_code.exp:
tests/warnings/warn_dead_procs.exp:
tests/warnings/warn_stubs.exp:
	Update these files to expect the better error messages we now generate.
2004-05-14 08:40:33 +00:00
Ralph Becket
a8ffd3680c Change the compiler and tools so that .' and not :' is now used as the
Estimated hours taken: 14
Branches: main

Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.

Infix `.' now has associativity yfx and priority 10.

NEWS:
	Report the change.

configure.in:
	Amend the test for an up-to-date Mercury compiler to check whether
	it recognises `.' as a module qualifier.

compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
	Change `:' to `.' as module separator for output.

compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
	As above.
	Fixed a bug where `.' was not being recognised as a module separator.

doc/reference_manual.texi:
	Report the change.

library/term_io.m:
	Ensure that infix `.' is written without surrounding spaces.

tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
	Test case added.
2003-01-17 05:57:20 +00:00
Simon Taylor
3aa9eef538 Add some extra warnings caused by the disabling
Estimated hours taken: 0.1

tests/warnings/simple_code.exp:
	Add some extra warnings caused by the disabling
	of double negation removal.
2000-02-04 23:59:18 +00:00
Fergus Henderson
ec86c88404 Merge in the changes from the existential_types_2 branch.
Estimated hours taken: 4

Merge in the changes from the existential_types_2 branch.

This change adds support for mode re-ordering of code involving
existential types.  The change required modifying the order of the
compiler passes so that polymorphism comes before mode analysis,
so that mode analysis can check the modes of the `type_info' or
`typeclass_info' variables that polymorphism introduces, so that
it can thus re-order the code accordingly.

This change also includes some more steps towards making existential data
types work.  In particular, you should be able to declare existentially
typed data types, the compiler will generate appropriate unification
and compare/3 routines for them, and deconstruction unifications for them
should work OK.  However, currently there's no way to construct them
except via `pragam c_code', and we don't generate correct RTTI for them,
so you can't use `io__write' etc. on them.

library/private_builtin.m:
compiler/accumulator.m:
compiler/bytecode_gen.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/code_util.m:
compiler/common.m:
compiler/dead_proc_elim.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/follow_code.m:
compiler/follow_vars.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/live_vars.m:
compiler/magic.m:
compiler/make_hlds.m:
compiler/mercury_compile.m:
compiler/mercury_to_c.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_util.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/pd_cost.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/purity.m:
compiler/quantification.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/simplify.m:
compiler/table_gen.m:
compiler/term_traversal.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
compiler/unused_args.m:
compiler/notes/compiler_design.html:
doc/reference_manual.texi:
tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/existential_data_types.m:
tests/hard_coded/typeclasses/existential_data_types.exp:
tests/warnings/simple_code.exp:
tests/hard_coded/Mmakefile:
tests/term/arit_exp.trans_opt_exp:
tests/term/associative.trans_opt_exp:
tests/term/pl5_2_2.trans_opt_exp:
tests/term/vangelder.trans_opt_exp:
tests/term/arit_exp.trans_opt_exp:
tests/term/associative.trans_opt_exp:
tests/term/pl5_2_2.trans_opt_exp:
tests/term/vangelder.trans_opt_exp:
tests/invalid/errors2.err_exp2:
tests/invalid/prog_io_erroneous.err_exp2:
tests/invalid/type_inf_loop.err_exp2:
tests/invalid/types.err_exp2:
tests/invalid/polymorphic_unification.err_exp:
tests/invalid/Mmakefile:
tests/warnings/simple_code.exp:
tests/debugger/queens.exp:
tests/hard_coded/Mmakefile:
tests/hard_coded/existential_reordering.m:
tests/hard_coded/existential_reordering.exp:
	Merge in the changes from the existential_types_2 branch.
1999-06-30 17:13:53 +00:00
Fergus Henderson
6f7e94e67d Undo previous change -- I had accidentally committed it on the
Estimated hours taken: 0.1

tests/warnings/simple_code.exp:
	Undo previous change -- I had accidentally committed it on the
	main branch rather than on the existential_types_2 branch.
1999-06-13 01:08:48 +00:00
Fergus Henderson
2c98328a0b Various changes to fix test case failures in the existential_types_2
Estimated hours taken: 8

Various changes to fix test case failures in the existential_types_2
branch.

compiler/simplify.m:
	Delete a bogus sanity check that I had added, since the check
	was failing even in cases which made perfect sense.
	(This one was stopping the compiler from bootstrapping.)

	Delete an obsolete XXX comment about something that has already
	been fixed.

	When converting polymorphic complicated unifications into
	calls to unification procedures, we need to insert the
	type_info variables into the goal_info non-locals set.

compiler/simplify.m:
compiler/det_report.m:
	Fix a couple of old XXXs: issue warnings when optimizing away
	goals with determinism failure or det goals that have no outputs.
	This is needed to ensure that we still issue a warning for several
	of the goals in tests/warnings/simple_code.m.  The previous
	warnings were no longer being issued because this optimization was
	optimization away the relevant code before it could be warned about.

tests/warnings/simple_code.exp:
	Update to reflect the new warnings.

compiler/dependency_graph.m:
	Don't include imported modes of pseudo_imported predicates
	(i.e. (in,in) modes of unification predicates) in the dependency
	graph.  The treatment of pseudo_imported predicates in
	dependency_graph.m needs to match the way they are treated
	by polymorphism.m and other parts of the compiler.

compiler/polymorphism.m:
	Update the headvars field of the proc_info for imported procedures
	to include the type_info variables.  This is necessary because
	some parts of the compiler (e.g. unused_args.m) depend on the
	headvars field being valid even for imported procedures.

	Also fix a bug introduced in my changes to polymorphism.m -- I was
	passing down the wrong HeadVars to polymorphism__produce_existq_tvars.

compiler/post_typecheck.m:
compiler/purity.m:
	Ensure that we always bind any unbound type variables to `void'
	before running polymorphism, even if there were type errors.
	This avoids some internal errors in polymorphism.m.

compiler/mercury_compile.m:
	Fix a formatting error in one of the progress messages.

compiler/modes.m:
compiler/unique_modes.m:
	Ensure that mode analysis always stops analysing things once the
	instmap becomes unreachable.  It already did this for conjunctions,
	most of the time, but there were several other cases
	(if-then-elses and switches) where it did not.
	The aim of this change is to stop mode inference from creating
	modes for procedures with initial insts `not_reached'.

compiler/modecheck_unify.m:
	Handle the case where an unification is initially inferred as
	a non-complicated unification, and then gets re-modechecked
	with the instmap being unreachable.  The code here was assuming
	that a non-complicated unification can never get turned into
	a complicated unification on re-modechecking, but `not_reached'
	unifications where being classified as complicated.
	The above change to modes.m and unique_modes.m should avoid this
	situation, but I thought it was safest to fix the code here too,
	just in case.

compiler/modes.m:
compiler/modecheck_call.m:
compiler/mode_util.m:
	Pass the type down to normalise_inst and ensure that for type_info
	types, it never return a unique inst.  The aim is to stop mode
	inference from inferring unique modes for the type_info arguments
	introduce by polymorphism.m, since unique modes are never useful
	for those arguments, and allowing mode inference to infer
	unique modes for them leads to it inferring unnecessarily many modes.

	(Without this change, the test case tests/valid/uniq_mode_inf_bug.m
	fails, due to a bug in the existing mode inference stuff unrelated
	to my polymorphism / existential types changes.  The bug is that
	modecheck_queued_procs needs to run ordinary mode analysis to a
	fixpoint before running determinism analysis, etc.)

tests/hard_coded/Mmakefile:
	Fix a bug: compile lp.m with the same options as bigtest.m.
	Without this, bigtest was getting link errors due to unsatisfied
	symbols in lp.m.  The problem was due to bigtest.m being compiled
	with intermodule optimization, and lp.m being compiled without
	intermodule optimization.  This lead to bigtest.o containing
	inlined references to local routines in lp.m, but lp.o not exporting
	those symbols because intermodule optimization had not been enabled
	when it was compiled.
1999-06-12 00:50:56 +00:00
Fergus Henderson
b852ffd462 Update the line numbers in the expected output;
Estimated hours taken: 0.1

tests/warnings/simple_code.exp:
	Update the line numbers in the expected output;
	my previous change to simple_code.m added a comment
	which caused the line numbers in the warnings to change.
1999-04-20 14:53:38 +00:00
Fergus Henderson
3018d7abb2 Perform some minor simplifications in mode analysis,
Estimated hours taken: 1.5

Perform some minor simplifications in mode analysis,
so as to provide more information to unique mode analysis.
Previously unique_modes.m was reporting spurious errors
for tests/hard_coded/bidirectional.m, because modes.m
produced output containing a subgoal of the form
`disj([Goal, conj([disj([])]])' instead of just `Goal',
and the presence of a disjunction then caused unique mode
analysis to make overly conservative assumptions.

compiler/modes.m:
	Ensure that we do not produce singleton conjunctions or disjunctions.
	Also, if the result of mode checking a disjunct is a (nested)
	disjunction, then merge it with the containing disjunction.
	If the nested disjunction is the empty disjunction (fail),
	then this means it will be deleted.

tests/hard_coded/Mmakefile:
	Re-enable the test case bidirectional.m, since the compiler now
	accepts it, due to the above change.

tests/warnings/simple_code.m:
tests/warnings/simple_code.exp:
	Update this test case, because the above change meant that the
	compiler no longer issues the warning about "this disjunct can
	never succeed" in cases like this -- mode analysis will already
	have optimized it away, before we even get to simplify.m (which
	handles those kinds of warnings).  This warning is not as
	important as allowing bidirectional code.
1999-04-16 08:08:08 +00:00
Simon Taylor
b2b4d9b40b Update the output, which changed because the removal of
Estimated hours taken: 0.1

tests/warnings/simple_code.m:
	Update the output, which changed because the removal of
	goals with no outputs was disabled (I think).
1998-08-25 10:26:26 +00:00
Simon Taylor
f2458bd34b Fix a bug reported by Philip Dart where "this disjunct cannot succeed"
Estimated hours taken: 2

Fix a bug reported by Philip Dart where "this disjunct cannot succeed"
warnings for predicates using sub-typing in modes were being output
without a context.

compiler/hlds_goal.m
	Add versions of true_goal and fail_goal which take
	a context for the goal.

compiler/simplify.m
	Pass a valid context to true_goal and fail_goal.
	Only report most of the --warn-simple-code messages if they
	occur for all modes of a predicate - this avoids spurious
	"this disjunct cannot succeed" warnings for sub-typing.

compiler/det_report.m
	Added det_report__is_any_mode_msg to return whether a
	message should only be reported if it occurs for all modes
	of a predicate.

compiler/passes_aux.m
	Add a task type update_pred_error for use by simplify.m.
1998-06-17 05:14:15 +00:00
Simon Taylor
3a8d2f4ca9 Test cases for the --warn-simple-code warnings.
Estimated hours taken: 0.2

tests/warnings/simple_code.{m,exp}
	Test cases for the --warn-simple-code warnings.
1997-04-28 00:05:26 +00:00