diff --git a/compiler/make_hlds.m b/compiler/make_hlds.m index 8df2df02c..a352c629a 100644 --- a/compiler/make_hlds.m +++ b/compiler/make_hlds.m @@ -1261,7 +1261,7 @@ module_add_class_method(Method, Name, Vars, Status, MaybePredIdProcId, di, uo) is det. module_add_instance_defn(Module0, Constraints, Name, Types, Interface, VarSet, - Status, _Context, Module) --> + Status, Context, Module) --> { module_info_classes(Module0, Classes) }, { module_info_instances(Module0, Instances0) }, { list__length(Types, ClassArity) }, @@ -1277,8 +1277,16 @@ module_add_instance_defn(Module0, Constraints, Name, Types, Interface, VarSet, Instances) }, { module_info_set_instances(Module0, Instances, Module) } ; - % XXX give an error since the class has not been - % XXX defined + io__stderr_stream(StdErr), + io__set_output_stream(StdErr, OldStream), + prog_out__write_context(Context), + io__write_string("Error: typeclass `"), + prog_out__write_sym_name(Name), + io__write_char('/'), + io__write_int(ClassArity), + io__write_string("' not defined.\n"), + io__set_exit_status(1), + io__set_output_stream(OldStream, _), { Module = Module0 } ). diff --git a/compiler/notes/compiler_design.html b/compiler/notes/compiler_design.html index ab08d22d3..c235fc562 100644 --- a/compiler/notes/compiler_design.html +++ b/compiler/notes/compiler_design.html @@ -313,12 +313,13 @@ in an HLDS goal. check_typeclass.m checks that, each instance declaration, that the types, modes and determinism of each predicate/function that is a method of the class is correct (ie. that it matches the typeclass - declaration). In this pass, pred_ids and proc_ids are assigned to - the methods for each instance. In addition, while checking that the - superclasses of a class are satisfied by the instance declaration, a - set of constraint_proofs are built up for the superclass constraints. - These are used by polymorphism.m when generating the - base_typeclass_info for the instance. + declaration). This pass is performed at the end of semantic analysis + because it needs mode and determinism information. In this pass, + pred_ids and proc_ids are assigned to the methods for each instance. In + addition, while checking that the superclasses of a class are satisfied + by the instance declaration, a set of constraint_proofs are built up + for the superclass constraints. These are used by polymorphism.m when + generating the base_typeclass_info for the instance.