[m-rev.] for review: fix state var compiler abort
Zoltan Somogyi
zs at cs.mu.OZ.AU
Mon Mar 8 13:26:04 AEDT 2004
For post-commit review by Ralph. The diff changes behavior only in cases where
the compiler used to abort.
Ralph, if you could document the intended semantics of the fields of the
svar_info type, including the invariants that they are supposed to obey,
I would be grateful.
Zoltan.
Fix a compiler abort reported by obo at ruk.cuni.cz.
compiler/make_hlds.m:
Avoid a compiler abort for clauses of the form p(!:X).
tests/invalid/state_vars_test5.{m,err_exp}:
New test case to check for a meaningful error message for such code.
tests/invalid/Mmakefile:
Enable the new test case.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.459
diff -u -b -r1.459 make_hlds.m
--- compiler/make_hlds.m 21 Dec 2003 05:04:35 -0000 1.459
+++ compiler/make_hlds.m 6 Mar 2004 06:39:55 -0000
@@ -9160,13 +9160,17 @@
:- func svar_unifiers(prog_context, svar_map, svar_map) = hlds_goals.
svar_unifiers(Context, LHSMap, RHSMap) =
- map__foldl(
- func(StateVar, Var, Unifiers) =
- [ svar_unification(Context,
- Var, RHSMap ^ det_elem(StateVar))
- | Unifiers ],
- LHSMap,
- []
+ map__foldl(add_svar_unifier(RHSMap, Context), LHSMap, []).
+
+:- func add_svar_unifier(svar_map, prog_context, svar, prog_var, hlds_goals)
+ = hlds_goals.
+
+add_svar_unifier(RHSMap, Context, StateVar, Var, Unifiers0) = Unifiers :-
+ ( RHSVar = RHSMap ^ elem(StateVar) ->
+ Unifier = svar_unification(Context, Var, RHSVar),
+ Unifiers = [Unifier | Unifiers0]
+ ;
+ Unifiers = Unifiers0
).
%------------------------------------------------------------------------------%
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.148
diff -u -b -r1.148 Mmakefile
--- tests/invalid/Mmakefile 20 Feb 2004 04:00:59 -0000 1.148
+++ tests/invalid/Mmakefile 6 Mar 2004 06:48:21 -0000
@@ -117,6 +117,7 @@
state_vars_test2 \
state_vars_test3 \
state_vars_test4 \
+ state_vars_test5 \
tc_err1 \
tc_err2 \
tricky_assert1 \
Index: tests/invalid/state_vars_test5.err_exp
===================================================================
RCS file: tests/invalid/state_vars_test5.err_exp
diff -N tests/invalid/state_vars_test5.err_exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/invalid/state_vars_test5.err_exp 6 Mar 2004 06:47:54 -0000
@@ -0,0 +1,7 @@
+state_vars_test5.m:021: In clause for predicate `state_vars_test5.p/1':
+state_vars_test5.m:021: warning: variable `STATE_VARIABLE_X' occurs only once in this scope.
+state_vars_test5.m:021: In clause for `p(out)':
+state_vars_test5.m:021: mode error: argument 1 did not get sufficiently instantiated.
+state_vars_test5.m:021: Final instantiatedness of `STATE_VARIABLE_X' was `free',
+state_vars_test5.m:021: expected final instantiatedness was `ground'.
+For more information, try recompiling with `-E'.
Index: tests/invalid/state_vars_test5.m
===================================================================
RCS file: tests/invalid/state_vars_test5.m
diff -N tests/invalid/state_vars_test5.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/invalid/state_vars_test5.m 6 Mar 2004 06:47:32 -0000
@@ -0,0 +1,21 @@
+%------------------------------------------------------------------------------%
+% vim: ft=mercury ff=unix ts=4 sw=4 et wm=0 tw=0
+%
+% This is a regression test. The versions of the compiler prior to 6 March 2004
+% used to get an exception inside the compiler code (in svar_unifiers in
+% make_hlds.m). This test checks that we get a meaningful error instead
+% of a compiler abort.
+%
+%------------------------------------------------------------------------------%
+
+:- module state_vars_test5.
+
+:- interface.
+
+:- import_module int.
+
+:- pred p(int::out) is det.
+
+:- implementation.
+
+p(!:X).
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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