mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 14:57:03 +00:00
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.