Commit Graph

4 Commits

Author SHA1 Message Date
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
Mark Brown
532bc4b86c Fix another problem with circularly defined insts.
Estimated hours taken: 0.5
Branches: main, release

Fix another problem with circularly defined insts.

compiler/make_hlds.m:
	When checking for circularly defined insts, substitute the correct
	arguments for user defined insts.  Use unrelated insts as the
	inital argument values (in this case, use not_reached for all of
	them).

tests/invalid/Mmakefile:
	Add some new tests.

tests/invalid/circ_inst5.err_exp:
tests/invalid/circ_inst5.m:
	A test case where looping occurs via an argument substitution.
	Before this change, attempting to compile this module would result
	in a loop.

tests/invalid/circ_type5.err_exp:
tests/invalid/circ_type5.m:
	A similar test case for equivalence types.  The algorithm to expand
	equivalence types already handled this case correctly, but it was
	untested.

	There is no corresponding test case for modes, since this kind of
	error cannot occur in mode declarations.
2003-01-12 02:45:22 +00:00