mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-26 23:04:15 +00:00
Estimated hours taken: 8 Branches: main Improve the detection of invalid instance declarations by doing the check during hlds checking rather than parsing, as we have more information then. compiler/check_typeclass.m: Add check_instance_declaration_types/4, where we check that each type the instance declaration must be either a type with no arguments, a polymorphic type whose arguments are all distinct type variables. compiler/error_util.m: Add nth_fixed to format_component which returns "first", "second", "third", "4th" depending on the given integer. compiler/prog_io_typeclass.m: Remove the invalid instance check during parsing. compiler/type_util.m: Fix a spelling mistake. tests/hard_coded/typeclasses/fundeps_1.m: tests/hard_coded/typeclasses/fundeps_2.m: tests/invalid/ambiguous_method.m: tests/invalid/ambiguous_method_2.m: Fix invalid instance declarations. tests/invalid/bad_instance.err_exp: tests/invalid/instance_dup_var.err_exp: Update to the new error messages. tests/invalid/Mmakefile: tests/invalid/invalid_instance_declarations.err_exp: tests/invalid/invalid_instance_declarations.m: Add a check where we use equivalence types to hide invalid typeclass declarations.
19 lines
382 B
Mathematica
19 lines
382 B
Mathematica
:- module invalid_instance_declarations.
|
|
:- interface.
|
|
|
|
:- type t(T) ---> f(T).
|
|
:- type t(T, U) ---> f(T, U).
|
|
|
|
:- typeclass tc(T) where [].
|
|
|
|
:- type e(T) == t(T, T).
|
|
:- type f(T) == ((func) = T).
|
|
:- type g(T) == {T, T}.
|
|
:- type h == t(int).
|
|
|
|
:- implementation.
|
|
:- instance tc(e(T)) where [].
|
|
:- instance tc(f(T)) where [].
|
|
:- instance tc(g(T)) where [].
|
|
:- instance tc(h) where [].
|