Commit Graph

8 Commits

Author SHA1 Message Date
Zoltan Somogyi
be8ecd7c9b Add "Error:" at the start of an error message. 2021-10-17 09:44:34 +11:00
Zoltan Somogyi
cfe6782dd2 Improve diagnostics for circular insts and modes.
compiler/add_mode.m:
    Improve diagnostics for circular insts and modes in several ways.

    - Generate one error message per cycle, not one error message per inst.
      In the case of cycles containing more than one inst or mode, this
      reduces clutter.

    - Unlike the old code, we do print a context for every inst or mode
      in a cycle, rather than just for the first.

    - Avoid module qualifying local inst and mode names unless that
      qualification actually avoids ambiguity.

    - Use more expansive wording that actually explains *why* a circular
      inst or mode is a problem.

tests/invalid/circ_inst5.m:
    Extend this test case to test corner cases of the new code.

tests/invalid/circ_inst.err_exp:
tests/invalid/circ_inst2.err_exp:
tests/invalid/circ_inst3.err_exp:
tests/invalid/circ_inst4.err_exp:
tests/invalid/circ_inst5.err_exp:
tests/invalid/circ_mode.err_exp:
tests/invalid/circ_mode2.err_exp:
tests/invalid/circ_mode3.err_exp:
tests/invalid/circ_mode4.err_exp:
    Expect the updated error messages.
2021-10-16 12:14:49 +11:00
Zoltan Somogyi
29ba71f6c7 Fix a bug in inst/mode circularity detection.
It allowed circular insts to be added to the HLDS undetected, which meant
a later pass got into an infinite loop.

compiler/make_hlds_passes.m:
    Check for circularities in inst definitions only *after* all insts
    have been added to the HLDS, because until then, a circularity check
    may fail not because of the absence of a circularity in the inst
    definitions in the program, but because of the absence of a circularity
    in the inst definitions *added to the HLDS so far*.

    Do likewise for mode definitions.

compiler/add_mode.m:
    To make the above possible, split the predicates that do
    circularity checks on insts and modes from the predicates that
    add insts and modes to the HLDS.

tests/invalid/circ_inst5.m:
    Reorder inst definitions to expose the infinite loop bug in compilers
    without this diff.

tests/invalid/circ_inst*.err_exp:
tests/invalid/circ_mode*.err_exp:
    In the case of mutually recursive pairs of insts or modes, expect
    error messages for both definitions, not just the later definition.
2021-10-11 07:23:01 +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
Julien Fischer
e069d16ab1 Do not display the For more information try recompiling with -E'' prompt
Estimated hours taken: 1.5
Branches: main

Do not display the `For more information try recompiling with `-E'' prompt
unless we really mean it, i.e. there is actually more information available.

XXX This change is incomplete for the mode_errors module because that
module requires more substantial changes to make this work - I'll do
that as a separate diff.

compiler/globals.m
	Add a new global (and access predicates) that keeps track of whether
	we have any verbose error information that could be displayed if we
	recompiled with `-E'.

compiler/mercury_compile.m
	Check the new global flag before prompting the user to recompile with
	`-E'.

compiler/mode_errors.m
	Add an XXX comment about needing to respect the extra error info flag
	properly.

compiler/accumulator.m
compiler/add_clause.m
compiler/add_pred.m
compiler/add_type.m
compiler/assertion.m
compiler/check_typeclass.m
compiler/det_report.m
compiler/magic_util.m
compiler/make_hlds_error.m
compiler/modes.m
compiler/module_qual.m
compiler/modules.m
compiler/post_typecheck.m
compiler/purity.m
compiler/stratify.m
compiler/typecheck_errors.m
	Set the new global flag when we come across an error
	for which we have a verbose error message.

tests/recompilation/*:
tests/invalid/*:
	Update expected error files.
2005-09-14 05:27:11 +00:00
Zoltan Somogyi
6df9a05856 This diff cleans up a bunch of modules. It has no algorithmic changes
Estimated hours taken: 10
Branches: main

This diff cleans up a bunch of modules. It has no algorithmic changes
other than in the formatting of error messages.

compiler/error_util.m:
	Delete the obsolete predicate append_punctuation, since the suffix
	format component can now do more, and do it more easily.

compiler/goal_util.m:
compiler/hlds_goal.m:
compiler/hlds_llds.m:
compiler/instmap.m:
compiler/const_prop.m:
	Change the argument order of some the predicates exported by these
	modules to make them easier to use with state variable syntax.

compiler/*.m:
	Convert a bunch of these modules to four space indentation, and fix
	departures from our coding style.

	Conform to the changed argument order above.

	Use suffixes instead of append_punctuation.

library/string.m:
	Add string.foldl2.

tests/invalid/circ_*.err_exp:
tests/warnings/unused_args_*.exp:
	Expect the updated error messages, which format sym_names consistently
	the same way as other messages.
2005-08-30 04:12:17 +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
Fergus Henderson
57d2006e2f Fix a bug where the compiler was going into an infinite loop for
Estimated hours taken: 16
Branches: main, release

Fix a bug where the compiler was going into an infinite loop for
insts and modes that are infinitely recursive at the top level,
e.g. `:- inst foo == foo.' or `:- mode foo == foo'.

compiler/make_hlds.m:
	Check for circular insts and modes, and report an error if any occur.

	Also, pass back a boolean from pass 1 indicating whether or not
	any cyclic insts and modes.  Rename the "UndefModes" argument
	for parse_tree_to_hlds as "InvalidModes", and set it to yes
	if there were any circular insts or modes, to ensure that
	mercury_compile.m will not run mode analysis.  This is needed
	to avoid infinite loops in mode analysis when processing
	circular

compiler/notes/compiler_design.html:
	Mention that make_hlds.m checks for circular insts and modes.
	Also mention that it expands state variable syntax.

compiler/mercury_compile.m:
	Add a comment about circular insts and modes to the list of
	reasons why we might need to stop before running mode analysis.

tests/invalid/circ_inst2.m:
	Fix a misleading comment.

tests/invalid/Mmakefile:
tests/invalid/circ_inst.err_exp:
tests/invalid/circ_inst2.err_exp:
tests/invalid/circ_inst3.err_exp:
tests/invalid/circ_inst4.err_exp:
tests/invalid/circ_mode.err_exp:
tests/invalid/circ_mode2.err_exp:
tests/invalid/circ_mode3.err_exp:
tests/invalid/circ_mode4.err_exp:
	Enable these test cases, and add expected output files for them.

tests/invalid/Mmakefile:
tests/invalid/circ_type3.m:
tests/invalid/circ_type3.err_exp:
	Add another test for circular equivalence types.
2002-11-22 13:20:17 +00:00