Files
mercury/tests/invalid/method_impl.m
Fergus Henderson 22e418f610 Improve the error message for errors in type class instance
Estimated hours taken: 1

Improve the error message for errors in type class instance
definitions that use the named (e.g. "pred(foo/N) is bar") syntax, as
suggested by Ralph Becket: for such procedures, just output "in bar/N"
rather than "in call to bar/N", since the user didn't write any
explicit call.

compiler/hlds_pred.m:
	Add a new marker `named_class_instance_method' to the pred_marker type.

compiler/hlds_out.m:
compiler/intermod.m:
	Handle the new marker.

compiler/check_typeclass.m:
	For instance methods defined using the named syntax,
	add the `named_class_instance_method' marker to their markers.

compiler/typecheck.m:
compiler/mode_errors.m:
	Pass the pred_markers down to hlds_out__write_call_arg_id.

compiler/hlds_out.m:
	Change hlds_out__write_call_arg_id so that for predicates with
	the `named_class_instance_method' marker, it doesn't output the
	"call to".

tests/invalid/Mmakefile:
tests/invalid/method_impl.m:
tests/invalid/method_impl.exp:
	A regression test.
2000-11-03 03:12:03 +00:00

38 lines
539 B
Mathematica

:- module method_impl.
:- interface.
:- import_module io.
:- pred main(io__state::di, io__state::uo) is det.
:- typeclass c(T) where [
pred m1(T::in, int::out) is det
].
:- type foo ---> foo.
:- type bar ---> bar.
:- instance c(foo) where [
pred(m1/2) is foo_m1
].
:- instance c(bar) where [
pred(m1/2) is bar_m1
].
:- pred foo_m1(foo::in, string::out) is det.
:- pred foo_m2(foo::in, int::in) is det.
:- implementation.
main -->
[].
:- pragma c_header_code("int foo_counter = 0;").
foo_m1(_, "forty two").
foo_m2(_, _).