[m-dev.] diff: stop compiling if typeclass errors found
David Glen JEFFERY
dgj at ender.cs.mu.oz.au
Thu May 11 14:59:21 AEST 2000
This diff fixes a bug reported by Tyson last night.
----------------------------------------------------------------------------
Estimated hours taken: 0.25
Stop compiling if errors were found by check_typeclass --- otherwise later
stages may get internal errors.
compiler/mercury_compile.m:
Check ``FoundTypeclassError'' as well as ``FoundTypeError'' and
``FoundPostTypecheckError'' when deciding whether or not to stop
compiling.
tests/invalid/tc_err1.m:
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.m:
tests/invalid/tc_err2.err_exp:
Two tests cases for this change. Previously these two cases both
resulted in a software error.
tests/invalid/Mmakefile:
Turn these tests on.
----------------------------------------------------------------------------
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mercury_compile.m,v
retrieving revision 1.160
diff -u -t -r1.160 mercury_compile.m
--- compiler/mercury_compile.m 2000/05/10 18:06:40 1.160
+++ compiler/mercury_compile.m 2000/05/11 04:45:54
@@ -747,7 +747,10 @@
{ HLDS = HLDS4 },
{ bool__or(FoundTypeError, FoundTypeclassError,
FoundError) }
- ; { FoundTypeError = yes ; FoundPostTypecheckError = yes } ->
+ ;
+ { FoundTypeError = yes ; FoundPostTypecheckError = yes
+ ; FoundTypeclassError = yes }
+ ->
%
% XXX it would be nice if we could go on and mode-check
% the predicates which didn't have type errors, but
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/invalid/Mmakefile,v
retrieving revision 1.64
diff -u -t -r1.64 Mmakefile
--- tests/invalid/Mmakefile 2000/05/06 06:23:19 1.64
+++ tests/invalid/Mmakefile 2000/05/11 04:50:46
@@ -62,6 +62,8 @@
record_syntax_errors.m \
some.m \
spurious_mode_error.m \
+ tc_err1.m \
+ tc_err2.m \
test_nested.m \
tricky_assert1.m \
type_inf_loop.m \
New File: tests/invalid/tc_err1.err_exp
===================================================================
tc_err1.m:025: Error: no determinism declaration for exported
tc_err1.m:025: predicate `tc_err1:handle_typedefs/3'.
tc_err1.m:028: In instance declaration for `tc_err1:actions(tc_err1:pstate)':
tc_err1.m:028: no implementation for type class predicate method
tc_err1.m:028: `tc_err1:handle_typedefs/3'.
tc_err1.m:028: In instance declaration for `tc_err1:actions/1': incorrect
tc_err1.m:028: method name(s).
For more information, try recompiling with `-E'.
New File: tests/invalid/tc_err1.m
===================================================================
%
% The following module gave a software error
% with the compiler of May 2nd 2000.
%
% tc_err1.m:015: Error: no determinism declaration for exported
% tc_err1.m:015: predicate `tc_err1:handle_typedefs/3'.
% tc_err1.m:018: In instance declaration for `tc_err1:actions(tc_err1:pstate)':
% tc_err1.m:018: no implementation for type class predicate method
% tc_err1.m:018: `tc_err1:handle_typedefs/3'.
% tc_err1.m:018: In instance declaration for `tc_err1:actions/1': incorrect
% tc_err1.m:018: method name(s).
% Uncaught exception:
% Software Error: missing determinism decl. How did we get this far?
% Stack dump not available in this grade.
%
:- module tc_err1.
:- interface.
:- type pstate ---> pstate.
:- typeclass actions(A) where [
pred handle_typedefs(int, A, A) is det,
mode handle_typedefs(in, in, out)
].
:- instance actions(pstate) where [
pred(handle_typedefs/2) is pstate_handle_typedefs
].
New File: tests/invalid/tc_err2.err_exp
===================================================================
tc_err2.m:034: In instance declaration for `tc_err2:actions(tc_err2:pstate)':
tc_err2.m:034: no implementation for type class predicate method
tc_err2.m:034: `tc_err2:handle_typedefs/3'.
tc_err2.m:034: In instance declaration for `tc_err2:actions/1': incorrect
tc_err2.m:034: method name(s).
For more information, try recompiling with `-E'.
New File: tests/invalid/tc_err2.m
===================================================================
%
% Ye-olde map lookup failed strikes again.
%
% tc_err2.m:024: In instance declaration for `tc_err2:actions(tc_err2:pstate)':
% tc_err2.m:024: no implementation for type class predicate method
% tc_err2.m:024: `tc_err2:handle_typedefs/3'.
% tc_err2.m:024: In instance declaration for `tc_err2:actions/1': incorrect
% tc_err2.m:024: method name(s).
% Uncaught exception:
% Software Error: map__lookup: key not found
% Key Type: prog_data:class_constraint
% Key Functor: constraint/2
% Value Type: hlds_data:constraint_proof
% Stack dump not available in this grade.
%
:- module tc_err2.
:- interface.
:- type pstate ---> pstate.
:- typeclass super(A) <= actions(A) where [
].
:- typeclass actions(A) where [
pred handle_typedefs(int, A, A),
mode handle_typedefs(in, in, out) is det
].
:- instance super(pstate) where [
].
:- instance actions(pstate) where [
pred(handle_typedefs/2) is id
].
:- pred foo(A) <= super(A).
:- mode foo(in) is det.
:- pred bar is det.
:- implementation.
bar :-
foo(pstate).
foo(A) :-
handle_typedefs(4, A, _).
----------------------------------------------------------------------------
dgj
--
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student, | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.| With sufficient formality
The University of Melbourne | The sheerist banality
Australia | Will be hailed by the critics: "Miraculous!"
| -- Anon.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list