Commit Graph

2 Commits

Author SHA1 Message Date
Zoltan Somogyi
46d1cfb3b7 Diagnose bad partial pred/func application.
compiler/typecheck_error_undef.m:
    When reporting an undefined name/arity pair, if the name happens
    to be name of some functions and/or predicates which all have
    different arities, add a sentence to the diagnostic to report this fact.
    (Normally this happens only when the erroneous code provides
    *too many* arguments, because if it does not, then the typechecker
    would know that the code can be read as constructing a closure, and
    would instead report errors for the arguments that have the wrong type.)

    Don't color a closing parenthesis whose open parenthesis
    is not colored.

    Fix an old bug that we have no test case for: add the missing
    initial part of the diagnostic for bugs that report undefined
    *non*-user-defined function symbols. There shouldn't be any such
    errors, but the types permit it ...

tests/invalid/wrong_arity_function.{m,err_exp}:
    Extend this test case to test diagnostic extension described above.

tests/invalid/coerce_syntax.err_exp:
    Expect the color change.
2025-01-05 00:25:00 +11:00
Zoltan Somogyi
3a29391990 Improve error messages for wrong arity function calls.
compiler/typecheck_errors.m:
    When we find a reference to an unknown function symbol/arity pair
    but the function symbol itself has definitions with other arities,
    we want to print those arities to help programmers diagnose the problem.
    When doing this, we used to take into account the arities only of the
    data constructor function symbols of the same name; we now also take
    into account the arities of the actual functions of the same name.

compiler/hlds_data.m:
    Simplify the code for returning the list of the relevant arities
    by not filtering out the actual (wrong) arity; this is now done
    by the caller in typecheck.m for *both* sources of arities.

tests/invalid/wrong_arity_function.{m,err_exp}:
    A test case for this fix.

tests/invalid/Mmakefile:
    Enable the new test case.
2016-06-22 13:29:28 +02:00