mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 11:54:02 +00:00
compiler/pre_typecheck.m:
Split the "final statevar is unneeded" warning into two categories,
based on whether the initial version of that statevar is also unused,
or not. Generate different messages for the two situations.
For the "initial version of the statevar is used" category,
add a heuristic which says: do *not* generate this warning
if the mode of either the initial or the final statevar argument
involves uniqueness. This is to allow for code that uses e.g.
an <mdi, muo> pair of statevar arguments, and whose body passes
the initial version to a predicate as an mui argument. In such cases,
you need the final statevar to tell the caller that call did not
destroy the uniqueness of the passed state.
compiler/goal_util.m:
Add a new version of the goal_vars predicate for use by the new code
in pre_typecheck.m.
compiler/hlds_markers.m:
Add missing word in module comment.
compiler/inst_test.m:
Fix the comments describing two predicates.
compiler/mercury_compile_front_end.m:
Add a way to dump the HLDS version that the statevar warnings code
works with. (We dump the HLDS from *after* the statevar warnings code
is run, but since that code leaves the HLDS unchanged, the now-dumped
HLDS is also its input.)
compiler/state_var.m:
Add a utility predicate for use by the new code in pre_typecheck.m.
tests/invalid/try_io_else.err_exp:
Expect the new warning text for the "neither initial nor final version
is needed" case.
tests/warnings/unneeded_final_statevar.{m,err_exp}:
Add a test case for the operation of the new heuristic.
tests/warnings/Mmakefile:
Enable the new test case.
538 B
538 B
try_io_else.m:019: In predicate `main'/2:
try_io_else.m:019: warning: the first argument and the second argument,
try_io_else.m:019: represented by the state variable `!IO', could be deleted,
try_io_else.m:019: because they are not used, and because the final value is
try_io_else.m:019: always the same as the initial value.
try_io_else.m:020: Error: a `try' goal with an `io' parameter cannot have an
try_io_else.m:020: `else' part.
try_io_else.m:019: warning: the first argument and the second argument,
try_io_else.m:019: represented by the state variable `!IO', could be deleted,
try_io_else.m:019: because they are not used, and because the final value is
try_io_else.m:019: always the same as the initial value.
try_io_else.m:020: Error: a `try' goal with an `io' parameter cannot have an
try_io_else.m:020: `else' part.