Commit Graph

4 Commits

Author SHA1 Message Date
Zoltan Somogyi
291879c8bb Move checks for type_infos to add_foreign_proc.m.
This allows to perform those checks for *all* foreign_procs,
not just the ones that get added to the HLDS.

compiler/add_foreign_proc.m:
    Move the code that checks the bodies of foreign_procs for the
    presence of type_info variables for existentially quantified
    type variables here from typecheck.m and typecheck_errors.m.
    Change the diagnostic's wording to match our new phraseology.

    Record identifiers in a set, not a list, for faster membership tests,
    since we now do even more of them.

compiler/foreign.m:
    Provide a mechanism to return the identifiers not just in the
    non-comment parts of foreign_procs, but the comment parts as well,
    since add_foreign_proc.m now needs this functionality.

compiler/make_hlds_warn.m:
    Conform to the change in foreign.m.

compiler/typecheck.m:
compiler/typecheck_errors.m:
    Delete the code that was moved (in a modified form)
    to add_foreign_proc.m.

compiler/ml_foreign_proc_gen.m:
    Update a reference in a comment.

tests/invalid/exist_foreign_error.err_exp:
    Expect the updated wording of the affected diagnostics,
    and expect diagnostics for *all* the foreign_procs in the test,
    regardless of which language they are for.

tests/invalid/exist_foreign_error.err_exp2:
tests/invalid/exist_foreign_error.err_exp3:
    Delete these files, since the output they expect is now
    in the .err_exp file.

tests/invalid/fp_dup_bug.err_exp2:
tests/invalid/fp_dup_bug.err_exp3:
tests/invalid/gh72_errors.err_exp2:
tests/invalid/gh72_errors.err_exp3:
    Expect the updated wording of diagnostics affected by previous
    changes (which updated the .err_exp files for C, not these for
    Java and C#).
2026-01-31 16:31:04 +11:00
Zoltan Somogyi
62d9fcbe4b Ignore (mostly) comments inside foreign_procs.
compiler/foreign.m:
    When returning the list of identifiers inside a foreign_proc's code,
    ignore the contents of comments. This means that warnings about
    variable names that occur in the foreign_proc's argument list
    but do not occur in the foreign_proc's code cannot be shut up anymore
    by mention the variable name in comments.

    The "mostly" part is that typecheck.m still looks at the bodies
    of foreign_procs without knowing about comments. Fixing that
    will be part a future change.

NEWS.md:
    Announce this breaking change.

compiler/fact_table_gen.m:
    When we try to generate a foreign_proc's body for a fact table
    but cannot do so due to the fact table file not being readable,
    add a marker to the predicate that the fact table is for.

compiler/hlds_markers.m:
    Update the documentation of the existing predicate marker
    we use for this.

compiler/make_hlds_warn.m:
    Do not warn about singleton variables in foreign_proc bodies
    that are empty due to missing fact table files.

library/array.m:
library/io.file.m:
library/profiling_builtin.m:
library/stm_builtin.m:
library/table_builtin.m:
library/term_size_prof_builtin.m:
tests/invalid/erroneous_throw_promise.m:
tests/invalid/foreign_procs_exist_type.m:
tests/invalid/foreign_purity_mismatch.m:
tests/invalid/gh72_errors.m:
tests/invalid_purity/purity.m:
tests/valid/solv.m:
    Shut up warnings about singletons in foreign_procs by adding a _ prefix
    to the names of the relevant arguments, and delete the comments
    that can no longer do that job.

tests/invalid/foreign_purity_mismatch.err_exp:
tests/invalid/gh72_errors.err_exp:
tests/invalid/gh72_errors.err_exp2:
tests/invalid/gh72_errors.err_exp3:
tests/invalid_purity/purity.err_exp:
    Expect updated line numbers.

tests/warnings/warn_return.{m,err_exp}:
    Extend this test case to test that

    - we DO warn about return statements outside comments, but
    - we DO NOT warn about return statements inside comments.
2026-01-28 13:34:30 +11:00
Zoltan Somogyi
feeff5d8b3 Expect updated/colorized error messages. 2025-09-03 18:15:07 +02:00
Zoltan Somogyi
f7a06c1f24 Fix a third batch of C# invalid test fails.
compiler/make.program_target.m:
    All the multimodule tests in tests/invalid_make_int have been failing
    in C# grades. The script for these tests has two main steps:

    - build all the .int3 files involved, and then
    - build the .int file.

    The second step is expected to fail, with its error messages being tested,
    but the first step is expected to succeed. The test cases were failing
    because mmc --make built the .int files as part of the FIRST stage.

    The cause was code that built all interface files (.int3, .int0,
    .int/.int2 and even .opt) as a preliminary first step before actually
    trying to act on *any* build-all target. The fix is to make this
    preliminary step build only the interface files that come before
    the build-all target's file kind in the build order. In this case,
    that means not building anything in the preliminatu step of the
    build-all-int3s target before building all the .int3s, thus leaving
    the construction of the .int file for the second step, which is
    *expected* to fail.

tests/invalid/exported_unify_helper_1.m:
    Rename exported_unify2.m to exported_unify_helper_1.m in accordance
    with our usual scheme.

tests/invalid/exported_unify.{m.err_exp,err_exp2}:
    Update both expected error files for the rename. Since the .err_exp2 file
    was ancient, this update fixed the test case failure for C# (and almost
    certainly for Java) bootchecks. Note the role of each expected output
    file in the source code.

tests/invalid/foreign_procs_exist_type.err_exp2:
tests/invalid/foreign_procs_exist_type.err_exp3:
    Add these files containing the expected outputs for Java and C#.

tests/invalid/foreign_procs_exist_type.m:
    Add a note about the role of each expected output file.

tests/invalid/foreign_procs_exist_type.err_exp:
    Update the line numbers for this file containing the C expected output.

tests/invalid/foreign_purity_mismatch.m:
tests/invalid/fp_dup_bug.m:
    For each C foreign proc being tested, add C# and Java foreign_procs
    as well.

    Add a note about the role of each expected output file.

tests/invalid/foreign_purity_mismatch.err_exp2:
tests/invalid/foreign_purity_mismatch.err_exp3:
tests/invalid/fp_dup_bug.err_exp2:
tests/invalid/fp_dup_bug.err_exp3:
    Add these files containing the expected outputs for Java and C#.

tests/invalid/foreign_purity_mismatch.err_exp:
tests/invalid/fp_dup_bug.err_exp:
    Update the line numbers for this file containing the C expected output.

tests/invalid/gh72_errors.m:
    This test case tests an error message from the direct arg transformation.
    This transform does not apply to C# and Java grades, so in those grades,
    the compiler does not generate those messages. In those grades, this
    test case failed because the compilation succeeds, instead of failing
    (with the expected message, or not).

    Fix this failure by adding to gh72_errors.m C# and Java foreign_procs
    that do get error messages.

tests/invalid/gh72_errors.err_exp2:
tests/invalid/gh72_errors.err_exp3:
    Expect these error messages in C# and Java grades respectively.

tests/invalid/gh72_errors.err_exp:
    Update the line numbers in the error messages during C compilations.
2023-10-26 08:47:39 +11:00