[m-dev.] diff: fix spurious warning about unbound polymorphism

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 18 01:15:12 AEDT 2000


On 15-Feb-2000, Mark Anthony BROWN <dougl at cs.mu.OZ.AU> wrote:
> The module included below gives a spurious warning about
> unbound polymorphism of the variable M.  The problem goes away
> if the explicit existential quantification is removed.
> The compiler used was a recently updated from the repository.

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.

Workspace: /d-drive/home/hg/fjh/ws-hg2/mercury
Index: compiler/quantification.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/quantification.m,v
retrieving revision 1.71
diff -u -d -r1.71 quantification.m
--- compiler/quantification.m	2000/02/10 04:47:38	1.71
+++ compiler/quantification.m	2000/02/15 07:33:18
@@ -368,8 +368,13 @@
 	quantification__set_outside(OutsideVars),
 	quantification__set_quant_vars(QuantVars).
 
+	% After this pass, explicit quantifiers are redundant,
+	% since all variables which were explicitly quantified
+	% have been renamed apart.  So we don't keep them.
+	% Thus we replace `if_then_else(Vars, ....)' with
+	% `if_then_else([], ...)'.
 implicitly_quantify_goal_2(if_then_else(Vars0, Cond0, Then0, Else0, SM),
-			Context, if_then_else(Vars, Cond, Then, Else, SM)) -->
+			Context, if_then_else([], Cond, Then, Else, SM)) -->
 	quantification__get_quant_vars(QuantVars),
 	quantification__get_outside(OutsideVars),
 	quantification__get_lambda_outside(LambdaOutsideVars),
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.51
diff -u -d -r1.51 Mmakefile
--- tests/valid/Mmakefile	2000/01/31 03:59:07	1.51
+++ tests/valid/Mmakefile	2000/02/17 14:07:41
@@ -101,6 +101,7 @@
 	parsing_bug_main.m \
 	pred_with_no_modes.m \
 	qualified_cons_id.m \
+	quantifier_warning.m \
 	same_length_2.m \
 	semidet_disj.m \
 	shape_type.m \
@@ -208,6 +209,7 @@
 MCFLAGS-middle_rec_labels	= --middle-rec --no-follow-vars 
 MCFLAGS-mostly_uniq_mode_inf	= --infer-all
 MCFLAGS-pred_with_no_modes	= --infer-all
+MCFLAGS-quantifier_warning	= --halt-at-warn
 MCFLAGS-simplify_bug		= -O-1
 MCFLAGS-two_way_unif		= -O-1
 MCFLAGS-type_inf_ambig_test	= --infer-all
Index: tests/valid/quantifier_warning.m
===================================================================
RCS file: quantifier_warning.m
diff -N quantifier_warning.m
--- /dev/null	Wed May  6 06:32:27 1998
+++ quantifier_warning.m	Fri Feb 18 01:06:34 2000
@@ -0,0 +1,36 @@
+% 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).


-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list