Files
mercury/tests/invalid/bug184.m
Julien Fischer ced413438c Add workarounds for bugs #184 and #214.
Bug #184 is a compiler abort due to the code that generates an error message
for an unsatisfied type class constraint.  That code is either making an
incorrect assumption about the constraint_map type or the there is a bug in the
type checker.  Bug #214 is also concerned with the error message for
unsatisfied type class constraints: in that case we attempt to list which goals
that are causing the unsatisfied constraints, but that list of goals is empty
and we end up with an incomplete looking error message.   (This is related to
bug #184 as once the the workaround for the abort is in place, the same thing
occurs there.)

compiler/post_typecheck.m:
     Do not assume that all unproven constraints will appears as values
     in the constraint map: that isn't true for the program in bug #184.

     If the list of goals that are causing unsatisfied type class constraints
     is empty, then omit the prefix "The unsatisfied constraints are
     due to:" from the error message.

tests/invalid/Mmakefile:
tests/invalid/Mercury.options.m:
tests/invalid/bug184.{m,err_exp}:
tests/invalid/bug214.{m,err_exp}:
     Add the test cases for the above bugs.
2016-06-29 21:54:40 +10:00

35 lines
913 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
%---------------------------------------------------------------------------%
% Regression test for bug #184.
% This program caused the compiler to abort with:
%
% Uncaught Mercury exception:
% Software Error: map.lookup: key not found
% Key Type: parse_tree.prog_data.prog_constraint
% Key Value: constraint(qualified(unqualified("bug184"), "myclass"),
% [type_variable(var(1), kind_star)])
% Value Type: set_ordlist.set_ordlist(hlds.hlds_data.constraint_id)
%
%---------------------------------------------------------------------------%
:- module bug184.
:- interface.
:- func test = int.
:- implementation.
:- import_module list.
test = f([]).
:- typeclass myclass(T) where [
func f(T) = int
].
:- instance myclass(list(T)) <= myclass(T) where [
f(_) = 4
].