Files
mercury/tests/invalid/state_vars_test_5.err_exp
Zoltan Somogyi 4f57c70ff7 Tweak and announce the unneeded statevar options.
compiler/pre_typecheck.m:
    Add a heuristic: do NOT generate a warning about unused final statevars
    if all of a predicate's clauses are facts. In such cases, the warnings
    are more noise than helpful.

compiler/add_clause.m:
    Record for each clause whether it is a fact.

compiler/hlds_clauses.m:
    Add a slot for this new fact_or_not flag.

compiler/add_foreign_proc.m:
compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/hlds_out_pred.m:
compiler/instance_method_clauses.m:
compiler/intermod.m:
compiler/typecheck.m:
compiler/typecheck_clauses.m:
compiler/unify_proc.m:
compiler/var_origins.m:
    Conform to the changes above.

compiler/options.m:
    Turn the options on by default. Their documentation already assumes this.

NEWS.md:
    Announce the new options warning about unneeded state variables.

tests/invalid/Mercury.options:
tests/invalid_purity/Mercury.options:
tests/invalid_nodepend/Mercury.options:
    Turn the new warn options off for test cases that

    - would otherwise get them, but
    - for which this is irrelevant to what they want to test for.

tests/invalid/state_vars_test_5.err_exp:
tests/invalid/try_io_else.err_exp:
tests/warnings/unify_x_f_x.err_exp:
    For these other cases, expect the new warnings.
2025-05-20 03:05:10 +10:00

917 B

state_vars_test_5.m:020: In predicate `p'/1:
state_vars_test_5.m:020: warning: state variable `!:X' is never updated in
state_vars_test_5.m:020: this clause, so it should be replaced with an
state_vars_test_5.m:020: ordinary variable.
state_vars_test_5.m:020: In clause for `p(out)':
state_vars_test_5.m:020: mode error: argument 1 did not get sufficiently
state_vars_test_5.m:020: instantiated.
state_vars_test_5.m:020: Final instantiatedness of `STATE_VARIABLE_X' was
state_vars_test_5.m:020: `free',
state_vars_test_5.m:020: expected final instantiatedness was `ground'.
state_vars_test_5.m:020: In clause for predicate `p'/1:
state_vars_test_5.m:020: warning: variable `STATE_VARIABLE_X' occurs only
state_vars_test_5.m:020: once in this scope.