[m-rev.] diff: double the typecheck ambiguity warning limit

Julien Fischer jfischer at opturion.com
Fri Nov 7 22:31:13 AEDT 2014


Hi Zoltan,

On Fri, 7 Nov 2014, Zoltan Somogyi wrote:

> On Fri, 7 Nov 2014 14:44:17 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
>> I think we
>> can increase this limit on modern machines without undue side effects and doing
>> so avoids spurious warnings.
>
> May I ask what code gets these spurious warnings?

Suprious was a bad choice of word on my part, the warnings are *not*
spurious in that they warn about things that affect the performance of
the type-checking algorithm.  The point I was trying to get across is
that IMO, the existing warning limit is too low.

Here is the predicate that motivated this change:

:- pred do_query_dt_entries_3(location_table::in,
     matrix::in, matrix::in,
     string::in, string::in, location_index::in, location_index::in,
     bool::in, bool::out, io::di, io::uo) is det.

do_query_dt_entries_3(LocnTable, DistanceMatrix, TimeMatrix,
         QueryLocnA, QueryLocnB, QueryIndexA, QueryIndexB,
         !IsFirst, !IO) :-
     KeyAB = {QueryIndexA, QueryIndexB},
     KeyBA = {QueryIndexB, QueryIndexA},
     TimeAB = lookup(TimeMatrix, KeyAB),
     TimeBA = lookup(TimeMatrix, KeyBA),
     DistanceAB = lookup(DistanceMatrix, KeyAB),
     DistanceBA = lookup(DistanceMatrix, KeyBA),
     LocnInfoA = lookup(LocnTable, QueryIndexA),
     LocnInfoB = lookup(LocnTable, QueryIndexB),
     (
         !.IsFirst = yes,
         !:IsFirst = no
     ;
         !.IsFirst = no,
         nl(!IO)
     ),
     format("%s: (%f, %f)\n",
         [s(QueryLocnA), f(LocnInfoA ^ locn_y), f(LocnInfoA ^ locn_x)], !IO),
     format("%s: (%f, %f)\n",
         [s(QueryLocnB), f(LocnInfoB ^ locn_y), f(LocnInfoB ^ locn_x)], !IO),
     format("%s -> %s: time %.2f minutes: distance %.2f kms.\n",
         [s(QueryLocnA), s(QueryLocnB), f(TimeAB), f(DistanceAB)], !IO),
     format("%s -> %s: time %.2f minutes: distance %.2f kms.\n",
         [s(QueryLocnB), s(QueryLocnA), f(TimeBA), f(DistanceBA)], !IO).

Also of relevance here are the module imports:

    :- import_module map.
    :- import_module multi_map.

The compiler warns about two sets of ambiguities here
(1) Whether the above calls to lookup are to map or multi_map.
     (They're all to map.lookup BTW.)
(2) Once we've added a module qualifier to those calls whether the
     symbol map.lookup is a the function map.lookup/2 or the predicate
     map.lookup/3.

Obviously, I am well aware that there are bunch of things I can do in
order to avoid the above ambiguities and hence the warnings.
At what point should I have to start doing those things though?
(My answer is not in the case of something like the above predicate.)

> I am not opposed to the doubling (I agree with your reason about why
> it shouldn't be a problem), but I also don't think it will be all that
> much help.

For some things I think increasing the limit will help.  For example,
people learning Mercury are likely to be discouraged by small programs
causing large numbers of warnings just because they've used the function
version of map.lookup.  Similarly, with bool.no vs. maybe.no.

As to how much the limit should be increased by, the original limit of
50 appears to have been fairly arbitrary, 100 was equally arbitrary on
my part.  I would note that --typecheck-ambiguity-error-limit is set to
3000, so perhaps the warning limit should be increased by quite a bit
more, say 1000?

Cheers,
Julien.



More information about the reviews mailing list