[m-rev.] diff: avoid error for type-infos in promise_equiv_solns scope

Julien Fischer juliensf at csse.unimelb.edu.au
Sat Apr 26 03:22:07 AEST 2008


Estimated hours taken: 0.5
Branches: main

Fix a bug reported by Ralph.  The compiler was reporting that type-info
related variables that were being bound in the body of a
promise_equivalent_solutions scope were not mentioned in the head of the
scope.  The error message should be restricted to those variables that
occur in the source code, not those introduced by the compiler.

compiler/det_analysis.m:
 	Do not consider type-info related variables when checking that
 	variables that are bound in the body of a promise_equivalent_solutions
 	scope are listed in the head of that scope.

tests/valid/Mmakefile:
tests/valid/promise_equiv_exists_non_local.m:
 	A regression test for the above problem.

Julien.

Index: compiler/det_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_analysis.m,v
retrieving revision 1.213
diff -u -r1.213 det_analysis.m
--- compiler/det_analysis.m	27 Feb 2008 07:23:04 -0000	1.213
+++ compiler/det_analysis.m	25 Apr 2008 15:56:19 -0000
@@ -124,6 +124,7 @@
  :- import_module parse_tree.mercury_to_mercury.
  :- import_module parse_tree.prog_data.
  :- import_module parse_tree.prog_out.
+:- import_module parse_tree.prog_type.

  :- import_module assoc_list.
  :- import_module bool.
@@ -1568,7 +1569,9 @@
          NonLocalVars = goal_info_get_nonlocals(GoalInfo),
          AnyBoundVars = set.filter(var_is_any_in_instmap(ModuleInfo, InstMap0),
              NonLocalVars),
-        BoundVars = set.union(GroundBoundVars, AnyBoundVars),
+        BoundVars0 = set.union(GroundBoundVars, AnyBoundVars),
+        proc_info_get_vartypes(ProcInfo, VarTypes),
+        BoundVars = remove_typeinfo_vars_from_set(VarTypes, BoundVars0),

          % Which vars were bound inside the scope but not listed
          % in the promise_equivalent_solution{s,_sets} or arbitrary scope?
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.211
diff -u -r1.211 Mmakefile
--- tests/valid/Mmakefile	22 Apr 2008 04:41:25 -0000	1.211
+++ tests/valid/Mmakefile	25 Apr 2008 15:56:20 -0000
@@ -183,6 +183,7 @@
  	param_mode_bug \
  	parsing_bug_main \
  	pred_with_no_modes \
+	promise_equiv_exists_non_local \
  	qualified_cons_id \
  	quantifier_warning \
  	record_syntax_bug \
Index: tests/valid/promise_equiv_exists_non_local.m
===================================================================
RCS file: tests/valid/promise_equiv_exists_non_local.m
diff -N tests/valid/promise_equiv_exists_non_local.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/valid/promise_equiv_exists_non_local.m	25 Apr 2008 15:56:20 -0000
@@ -0,0 +1,39 @@
+% vim: ft=mercury ts=4 sw=4 et
+%
+% rotd-rotd-2008-04-25 reported the following error for this program:
+%
+% Error: the `promise_equivalent_solutions'
+%   goal binds a variable that is not
+%   listed: TypeInfo_for_S.
+%
+% The problem was that the check that was generating this message
+% should not have been considering introduced type-info related
+% variables.
+%
+:- module promise_equiv_exists_non_local.
+:- interface.
+
+:- import_module list.
+
+:- some [S] pred test(list(int)::in, S::out) is semidet.
+
+:- implementation.
+
+test(I, S) :-
+    promise_equivalent_solutions [S] (
+        make_foo(I, Foo),
+        Foo = foo(S)
+    ).
+
+:- type foo ---> some [S] foo(S).
+
+:- pred make_foo(list(int)::in, foo::out) is nondet.
+
+make_foo(Xs, Foo) :-
+    list.member(X, Xs),
+    make_foo_2(X, Foo).
+
+:- pred make_foo_2(int::in, foo::out) is det.
+
+make_foo_2(X, 'new foo'(X)).
+

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list