mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-09 10:52:24 +00:00
Estimated hours taken: 2 Branches: main Fix a bug in the termination analyser where setting the termination norm to `num-data-elems' causes the an internal abort when analysing code involving existential typeclass constraints. The bug is caused by the length of the list of arguments of a functor differing from the length of the list in the weight table that tells the compiler which arguments to count when computing the size of that functor. The length mismatch is caused by typeinfo related variables that are introduced by the compiler for existentially typed terms. The termination analyser includes them but the weight table does not. I committed a diff a few months ago that partially fixed this problem, but programs that use existential typeclass constraints break that fix as well. The diff implements the easiest solution to all this which is to have the termination analyser remove all the typeinfo related arguments of a term before calling term_norm.functor_norm/9. This diff also fixes a few things in the tests/term directory, namely making sure that we actually run the tests, updating the module qualifier in a few .trans_opt_exp files and updating some comments. compiler/term_norm.m: Ignore any typeinfo related arguments that a term has when building the weight table. compiler/term_traversal.m: Remove any typeinfo related arguments from the lists of arguments and modes before computing the size of a term. tests/term/Mercury.options: tests/term/existential_error3.m: tests/term/existential_error3.trans_opt_exp: Add a regression test for this bug. tests/term/Mmakefile: Make sure the $(TESTS) and $(PROGS) variables are fully defined before Mmake.common is included, otherwise the tests will not run. Add the new regression test. tests/term/existential_error1.m: tests/term/existential_error2.m: The code that caused these bugs has been moved from term_util.m to term_norm.m. Update the references to the old filename. tests/term/*.trans_opt_exp: Replaces instances of `:' as the module qualifier with `.'. Quite a few tests cases were failing because the .trans_opt files use the latter.
3 lines
145 B
Plaintext
3 lines
145 B
Plaintext
:- module pl4_4_3.
|
|
:- pragma termination_info(pl4_4_3.merge((builtin.in), (builtin.in), (builtin.out)), finite(0, [yes, yes, no]), cannot_loop).
|