Commit Graph

2 Commits

Author SHA1 Message Date
Zoltan Somogyi
fdd141bf77 Clean up the tests in the other test directories.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the tests
    that check compiler error messages, expect the new line numbers.

browser/cterm.m:
browser/tree234_cc.m:
    Import only one module per line.

tests/hard_coded/boyer.m:
    Fix something I missed.
2015-02-16 12:32:18 +11:00
Zoltan Somogyi
91ce3a67a2 Avoid a compiler abort when people put a period in the middle of a clause.
The abort was caused by the fact that when the parser found an item that
looks like a fact for an undeclared predicate, such as the predicate ','/,
it created a hlds_pred filled with a clause_info in which terms that the
user intended to be goals are instead taken to be terms. Any reference
to predicates in those terms are taken by purity-checking to be higher order
references, which need a mode declaration. If the reference is to a predicate
(such as ,/2) whose declaration is implicit, that mode declaration will be
missing.

The fix has two parts. First, do not generate an abort in purity checking
when finding the mode declaration of a predicate or function in (what seems to
be) a higher order term is missing. Second, do not generate implicit
declarations for ,/2, since this is NEVER what the user wants.

A third part of this diff is an improvement in the contexts we record
for terms, for better error messages. I noticed the need for this when
looking at the compiler's output for the new cases.

compiler/post_typecheck.m:
   When finding an apparent reference to a predicate or function with
   no mode declarations, do not abort; instead, report an error.

compiler/purity.m:
   Record the error reported by post_typecheck.m.

compiler/add_clause.m:
   If we see a clause for `,'/2, do NOT treat it as implicitly defining
   a ,/2 predicate. Instead, generate a situation-specific error message that
   mentions the usual cause of the error.

compiler/add_pred.m:
   Clean up the predicates that add the implicit predicate declarations
   by making them both update module_infos, and by putting their arguments
   into a consistent order.

compiler/make_hlds_passes.m:
   Do likewise for a couple of predicates here.

compiler/add_pragma.m:
   Conform to the change to add_pred.m.

compiler/superhomogeneous.m:
   When expanding a term such as

      line 1: p(a,
      line 2: p(b,
      line 3: c))

   associate line 2 with the unification of a fresh variable with b,
   and line 3 with the unification of a fresh variable with c. We used
   to use the context of the top level term, which in this case is line 1,
   instead.

   This makes the compiler generate better (less misleading) output for the
   ref_to_implicit_pred.m test case below, as well as in many other cases.

compiler/state_var.m:
   When replacing !.X or !:X with a fresh variable term, copy the context
   of the original functor term to the new variable term. Before the change
   to superhomogeneous.m, this wasn't needed since the context of that term
   was ignored, but now we use it.

tests/invalid/ref_to_implicit_pred.{m,err_exp}:
   New test case to test the first part of the fix.

tests/invalid/ref_to_implicit_comma.{m,err_exp}:
   New test case to test the second part of the fix.

tests/invalid/Mmakefile:
   Enable both new test cases.

tests/hard_coded/impl_def_literal.{m,exp}:
   Update this expected output for the more accurate contexts we now
   generate, and update the comment in the source code accordingly.

tests/invalid/ambiguous_overloading_error.exp:
tests/invalid/max_error_line_width.err_exp:
tests/invalid/transitive_import_class.err_exp:
tests/warnings/ambiguous_overloading.exp:
   Update these expected outputs for the more accurate contexts we now
   generate.
2014-04-17 23:14:49 +10:00