[mercury-users] Duplication of warnings

David Overton david at overtons.id.au
Sun Jul 30 23:45:13 AEST 2006


On 29/07/06, Jonathan Morgan <jonmmorgan at gmail.com> wrote:
> If I write code like the following:
>
>         Test1 = 1,
>         Test = ( Test1 = 0 ->
>                         1
>                 ;
>                         2
>                 )
>
> I get warnings about Test occuring only once twice, like the following:
>
> test.m:010: In clause for predicate `test.main/2':
> test.m:010:   warning: variable `Test' occurs only once in this scope.
> test.m:010: In clause for predicate `test.main/2':
> test.m:010:   warning: variable `Test' occurs only once in this scope.
>
> Similarly, if I add more conditions then I get the warning as many
> times as the variable can be assigned to.  Is this expected behaviour?
>  It certainly doesn't seem desirable to me to duplicate warnings.

My guess is that the functional conditional is being expanded to a goal before
variable quantification.  I.e, it becomes

         Test1 = 1,
         ( Test1 = 0 ->
		 Test = 1
	 ;
		 Test = 2
	 )

Mercury's quantification (i.e. scoping) rules would then treat each occurrence
of Test as a separate variable.  While I would argue that this is a bug, I
don't think it's a very serious one because the variable Test is not used
anyway.  The only obvious symptom of this behaviour is that the error message
is duplicated, as you have noted.

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



More information about the users mailing list