mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-21 12:23:44 +00:00
Estimated hours taken: 1.5 Fix a spurious warning bug reported by Mark Brown. compiler/quantification.m: Change quantification.m so that for quantified variables from quantifiers in if-then-elses, after it has renamed apart all their occurrences, it eliminates the variables from the quantifier. This change matches what we currently do for the quantified variables in ordinary existentially quantication goals, and is needed to avoid spurious warnings about those variables having unbound types (their type remains unbound because after all occurrences have been renamed apart they don't actually occur anywhere in the goal anymore other than in the quantifier). tests/valid/Mmakefile: tests/valid/quantifier_warning.m: Add a regression test for the above bug-fix.
37 lines
523 B
Mathematica
37 lines
523 B
Mathematica
% The compiler used to issue a spurious warning
|
|
% about `M' having an unbound type.
|
|
:- module quantifier_warning.
|
|
:- interface.
|
|
:- import_module io.
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
:- implementation.
|
|
:- import_module std_util, int, bool.
|
|
|
|
main -->
|
|
{ p(1, R) },
|
|
io__write(R),
|
|
io__nl.
|
|
|
|
:- pred p(int::in, bool::out) is det.
|
|
|
|
p(N, R) :-
|
|
(
|
|
some [M] (
|
|
M > 5,
|
|
q(N, M)
|
|
)
|
|
->
|
|
R = yes
|
|
;
|
|
R = no
|
|
).
|
|
|
|
:- pred q(int::in, int::out) is nondet.
|
|
|
|
q(0, 0).
|
|
q(1, 1).
|
|
q(1, 2).
|
|
q(1, 3).
|
|
q(2, 2).
|
|
q(2, 4).
|