[m-rev.] for review: fix bug #257

Peter Wang novalazy at gmail.com
Tue May 21 10:30:23 AEST 2013


On Mon, 20 May 2013 17:44:43 +1000 (EST), Julien Fischer <jfischer at opturion.com> wrote:
> 
> For review by anyone.
> 
> Branches: master, 13.05
> 
> -------------------
> 
> Fix bug #257.
> 
> Emit a warning if the variable that is the subject of a require_complete_switch
> scope does not occur in the sub-goal.
> 
> compiler/det_report.m:
>  	As above.
> 
> tests/valid/Mmakefile:
> tests/valid/bug257b.{m,exp}:
> tests/warnings/Mmakefile:
> tests/warnings/bug257.{m,exp}:
>  	Test cases for the above.
> 
> Julien.
> 
...
> diff --git a/tests/valid/bug257b.m b/tests/valid/bug257b.m
> new file mode 100644
> index 0000000..e3dbbca
> --- /dev/null
> +++ b/tests/valid/bug257b.m
> @@ -0,0 +1,23 @@
> +% Don't emit an erroneous warning about the variable that is the subject
> +% of a require_complete_switch scope not occurring in the sub-goal if
> +% the sub-goal in question is not a switch and the varialbe in question

variable

> +% does not occur in the non-local set of the sub-goal.
> +% (See also tests/warning/bug257b.m.)

tests/warnings/bug257.m

> +
> +:- module bug257b.
> +:- interface.
> +
> +:- import_module io.
> +
> +:- type xyz ---> x ; y ; z.
> + 
> +:- pred oops(xyz::in, int::out, io::di, io::uo) is det.
> + 
> +:- implementation.
> +
> + oops(_G, N, !IO) :-
> +   require_complete_switch [Gee] (
> +	Gee = 123,
> +	io.write(Gee, !IO),
> +	N = 3
> +   ).
> diff --git a/tests/warnings/Mmakefile b/tests/warnings/Mmakefile
> index c712e31..0225d6f 100644
> --- a/tests/warnings/Mmakefile
> +++ b/tests/warnings/Mmakefile
> @@ -14,6 +14,7 @@ COMPILE_PROGS=	\
> 
>   ERRORCHECK_PROGS= \
>   	ambiguous_overloading \
> +	bug257 \
>   	det_infer_warning \
>   	double_underscore \
>   	duplicate_call \
> diff --git a/tests/warnings/bug257.exp b/tests/warnings/bug257.exp
> new file mode 100644
> index 0000000..270c61d
> --- /dev/null
> +++ b/tests/warnings/bug257.exp
> @@ -0,0 +1,2 @@
> +bug257.m:015: Warning: variable `Gee' in require_complete_switch scope does
> +bug257.m:015:   does not occur in the goal.

Maybe:

    Warning: variable `Gee' is the subject of a require_complete_switch
    scope but does not occur in the sub-goal.

Thanks for fixing it.

Peter



More information about the reviews mailing list