[m-rev.] diff: fix unbound variable bug in erlang backend
Peter Wang
novalazy at gmail.com
Thu Oct 4 15:19:37 AEST 2007
Estimated hours taken: 0.5
Branches: main
compiler/erl_code_gen.m:
Fix a bug in the Erlang code generator where a call to a predicate
with determinism `failure' can be followed by references to unbound
variables.
tests/valid/Mmakefile:
tests/valid/call_failure.m:
Add test case.
Index: compiler/erl_code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/erl_code_gen.m,v
retrieving revision 1.27
diff -u -r1.27 erl_code_gen.m
--- compiler/erl_code_gen.m 3 Oct 2007 03:33:24 -0000 1.27
+++ compiler/erl_code_gen.m 4 Oct 2007 05:20:05 -0000
@@ -473,6 +473,13 @@
% aborted before binding them).
MaybeSuccessExpr = no
;
+ Determinism = detism_failure
+ ->
+ % This goal can't succeed. As above we don't want to pass a
+ % success expression, but we must pass something to maintain the
+ % invariant that a model_semi goal has a success expression.
+ MaybeSuccessExpr = yes(elds_term(elds_fail))
+ ;
MaybeSuccessExpr = MaybeSuccessExpr0
),
erl_gen_goal_expr(GoalExpr, GoalCodeModel, Determinism, InstMap,
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.197
diff -u -r1.197 Mmakefile
--- tests/valid/Mmakefile 4 Oct 2007 00:36:52 -0000 1.197
+++ tests/valid/Mmakefile 4 Oct 2007 05:20:05 -0000
@@ -61,6 +61,7 @@
any_matches_bound \
big_foreign_type \
builtin_false \
+ call_failure \
common_struct_bug \
compl_unify_bug \
complicated_unify \
Index: tests/valid/call_failure.m
===================================================================
RCS file: tests/valid/call_failure.m
diff -N tests/valid/call_failure.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/valid/call_failure.m 4 Oct 2007 05:20:05 -0000
@@ -0,0 +1,24 @@
+:- module call_failure.
+:- interface.
+
+:- pred foo(int::in, int::out) is failure.
+
+:- implementation.
+
+:- import_module int.
+:- import_module require.
+
+foo(X, Y) :-
+ ( X = 42 ->
+ bar(X, Y0),
+ Y = Y0 + 1
+ ;
+ error("foo")
+ ).
+
+:- pred bar(int, int).
+:- mode bar(in(bound(42)), out) is failure.
+:- pragma no_inline(bar/2).
+
+bar(42, _) :-
+ fail.
--------------------------------------------------------------------------
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