[m-rev.] diff: fix deprecated lambda syntax warning

Julien Fischer juliensf at cs.mu.OZ.AU
Mon Aug 30 15:58:33 AEST 2004


Branches: main
Estimated hours taken: 0.5

Move a call to a predicate that uses the IO state that
was incorrectly placed in the condition of an if-then-else.
The compiler currently doesn't pick up on this at lower
levels of optimization, but will complain at higher ones.

compiler/make_hlds.m:
	Move the code that generates warnings for deprecated
	lambda syntax out of the condition of an if-then-else.

Julien.

Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.477
diff -u -r1.477 make_hlds.m
--- compiler/make_hlds.m	27 Aug 2004 05:07:06 -0000	1.477
+++ compiler/make_hlds.m	30 Aug 2004 05:45:36 -0000
@@ -7520,18 +7520,14 @@
 			parse_lambda_expression(LambdaExpressionTerm,
 				Vars0, Modes0, Det0)
 		->
-			report_warning(Context, 0,
-			[words("Warning: deprecated lambda expression syntax."), nl,
-			 words("Lambda expressions with lambda as the top-level functor"),
-			 words("are deprecated; please use the form using pred instead.")],
-				!IO),
 			LambdaPurity = (pure),
 			PredOrFunc = predicate,
 			EvalMethod = EvalMethod0,
 			Vars1 = Vars0,
 			Modes1 = Modes0,
 			Det1 = Det0,
-			GoalTerm1 = GoalTerm0
+			GoalTerm1 = GoalTerm0,
+			WarnDeprecatedLambda = yes
 		;
 			% handle higher-order pred and func expressions -
 			% same semantics as lambda expressions, different
@@ -7552,9 +7548,19 @@
 				parse_func_expression(HeadTerm, EvalMethod,
 					Vars1, Modes1, Det1),
 				PredOrFunc = function
-			)
+			),
+			WarnDeprecatedLambda = no
 		)
 	->
+		( WarnDeprecatedLambda = yes ->
+			report_warning(Context, 0,
+			[words("Warning: deprecated lambda expression syntax."), nl,
+			 words("Lambda expressions with lambda as the top-level functor"),
+			 words("are deprecated; please use the form using pred instead.")],
+				!IO)
+		;
+			true
+		),
 		check_expr_purity(Purity, Context, !Info, !IO),
 		make_hlds__qualify_lambda_mode_list(Modes1, Modes, Context,
 			!Info, !IO),

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list