[m-rev.] for review: work around bug #142

Julien Fischer juliensf at csse.unimelb.edu.au
Mon May 10 13:45:03 AEST 2010


On Mon, 10 May 2010, Peter Wang wrote:

> I don't know what the proper fix should be.

I've asked Mark to take a look at this, although he has quite
a bit of G12 stuff to do at the moment.

> Branches: main, 10.04
>
> Work around bug #142.  The symptom is an assertion failure in
> hlds.hlds_rtti.apply_substs_to_constraint_map.  It occurs when:
>
> - a variable holding a typeclass_info is used multiple times in a call;
> - the called procedure is inlined into the caller;
> - the corresponding head variables have class constraints with functional
>  dependencies;
> - the type variables in those constraints should be unified, but type variables
>  in the ranges of functional dependencies are not unified;
> - a single typeclass_info variable ends up being for two different constraints.
>
> The work around adopted here is to prevent inlining of a call when a single
> typeclass_info variable appears multiple times in the argument list, for which
> the head variables have differing class constraints.
>
> compiler/inlining.m:
>        As above.
>
> tests/valid/Mercury.options:
> tests/valid/Mmakefile:
> tests/valid/bug142.m:
>        Add test case.
>
> diff --git a/compiler/inlining.m b/compiler/inlining.m

...

> diff --git a/tests/valid/bug142.m b/tests/valid/bug142.m
> new file mode 100644
> index 0000000..6a514c9
> --- /dev/null
> +++ b/tests/valid/bug142.m
> @@ -0,0 +1,53 @@
> +% Regression test for bug 142.
> +%
> +% mmc --optimise-higher-order --inline-single-use -C bug142.m
> +% Uncaught Mercury exception:
> +% Software Error: hlds_rtti.m: Unexpected: inconsistent typeclass_infos

I suggest adding a note that points readers to the workaround in the
inlining module.

> +:- module bug142.
> +:- interface.
> +
> +:- type r(T)
> +    --->    ok(T)
> +    ;       err.
> +
> +:- type dcg(T, State) == (pred(r(T), State, State)).
> +:- mode dcg           == in(pred(out, in, out) is det).
> +
> +:- typeclass dcg(Token, State) <= ((State -> (Token))) where [
> +].
> +
> +:- pred or(dcg(T, State)::dcg, dcg(T, State)::dcg,
> +    r(T)::out, State::in, State::out) is det <= dcg(Token, State).
> +
> +:- pred orr(dcg(T, State)::dcg, dcg(T, State)::dcg, dcg(T, State)::dcg,
> +    r(T)::out, State::in, State::out) is det <= dcg(Token, State).

That looks fine otherwise.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list