Commit Graph

4006 Commits

Author SHA1 Message Date
Julien Fischer
383c2c307f Fix failure of trailing/test_trail_reset on Windows.
tests/trailing/test_trail_reset.m:
     Fix mismatched conversion specifier and cast.
2023-07-10 00:11:29 +10:00
Julien Fischer
f999105ad4 Fix the failure tests/hard_coded/write_xml on Windows.
tests/hard_coded/write_xml.m:
tests/hard_coded/write_xml.exp4:
     Add an expected output for the low-level C grades on Windows.
2023-07-09 13:23:31 +10:00
Julien Fischer
0e980917e1 Fix the failure tests/hard_coded/write_xml on Windows.
tests/hard_coded/write_xml.m:
    Update the comment at the head of this module that explains the
    differences between the expected outputs.

tests/hard_coded/write_xml.exp3:
    Expected output for this test on in a high-level C grade on Windows.
2023-07-08 23:16:12 +10:00
Julien Fischer
837a677c37 Fix failure of test/hard_coded/nonascii on Windows.
The Substitute character (U+001A) is treated as EOF for text mode files on
Windows. Omit that character from the test.

tests/hard_coded/nonascii_gen.c:
    Do not emit U+001A in the set of test characters.

tests/hard_coded/nonascii.m:
    Conform to the above change.

    Update syntax in a spot.

tests/hard_coded/nonascii.exp:
    Conform to the above change.
2023-07-08 21:30:45 +10:00
Julien Fischer
b1ebb1b35e Replace tabs with spaces.
tests/hard_coded/nonascii_gen.c:
    As above. Add the usual vim modeline.
2023-07-08 20:58:24 +10:00
Julien Fischer
67b4b12b2c Fix a test failure on Windows.
tests/invalid_nodepend/fact_table_in_interface.err_exp2:
    Add an expected output for systems where the .exe executable
    extension is used.

tests/invalid_nodepend/fact_table_in_interface.m:
    Document what the different expected outputs are for.

tests/invalid_nodepend/fact_table_in_interface.err_exp:
    Conform to line number changes.
2023-07-08 20:19:00 +10:00
Julien Fischer
8a130986d5 Fix a test failure on Windows.
tests/invalid/foreign_include_file_missing.{m,err_exp2}:
    Handle the case where "\" is used as the directory separator.
2023-07-08 16:58:44 +10:00
Julien Fischer
c16f53c0a3 Fix some test failures on Windows.
tests/invalid_options_file/inf_incl_direct.err_exp2:
tests/invalid_options_file/inf_incl_indirect.err_exp2:
tests/invalid_options_file/nonexistent_file.err_exp2:
     Handle the case where "\" is used as the directory separator.

tests/invalid_options_file/inf_incl_direct.m:
tests/invalid_options_file/inf_incl_indirect.m:
tests/invalid_options_file/nonexistent_file.m:
    Document what each of the .err_exp files corresponds to.
2023-07-08 16:49:20 +10:00
Peter Wang
7ba2f4d5c4 Fix typo causing compilation failure. 2023-07-06 17:40:34 +10:00
Zoltan Somogyi
b6ec42a132 Make some arities into pred_form_arities.
compiler/hlds_pred.m:
    Replace the arity field in pred_infos with a pred_form_arity field.

    Move the pred_info's pred_or_func field to its usual position
    in predicate/function descriptions: at the front (pred/func name/arity).

compiler/hlds_pred.m:
    Change two utility operations to return pred_form_arities instead of
    just arities, since they get them from pred_infos.

compiler/inst_mode_type_prop.m:
compiler/llds.m:
compiler/rtti.m:
    Change some fields whose types used to be arity (or int) to be
    pred_form_arity.

    In llds.m, include a pred_or_func field in c_procedures,
    for use in procedure-start comments.

mdbcomp/prim_data.m:
mdbcomp/program_representation.m:
    Add notes about two possible future improvements along similar lines.

compiler/prog_data.m:
    Add a utility function to calculate the number of extra arguments
    added to predicates/functions by compiler passes such as polymorphism.

compiler/add_pragma.m:
    Conform to the changes above.

    Fix a bug in an error message about ":- external" pragmas:
    the message used the pred_form arity instead of the user arity.
    (See the diff to external2.err_exp below.)

compiler/hlds_defns.m:
    Conform to the changes above.

    Include pred/func prefixes before name/arity pairs in the output
    where relavnt. (The user guide does not need to be updated, because
    its wording permits both the old and the new behavior.)

    Fix two separate bugs that referred to functions in user-facing output
    with the predicate form of their arity.

compiler/table_gen.m:
compiler/unused_args.m:
    Conform to the changes above.

    Fix a bug in each module that referred to functions in user-facing output
    with the predicate form of their arity.

compiler/recompilation.usage.m:
compiler/xml_documentation.m:
    Conform to the changes above.

    Mark a probable bug in each module with an XXX.

compiler/direct_arg_in_out.m:
    Conform to the changes above.

    Improve the wording of an error message a bit.
    (See the diff to gh72_errors.err_exp below.)

compiler/accumulator.m:
compiler/bytecode_gen.m:
compiler/complexity.m:
compiler/default_func_mode.m:
compiler/det_report.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/exception_analysis.m:
compiler/higher_order.m:
compiler/hlds_defns.m:
compiler/hlds_error_util.m:
compiler/hlds_module.m:
compiler/intermod.m:
compiler/intermod_order_pred_info.m:
compiler/introduce_exists_casts.m:
compiler/introduce_parallelism.m:
compiler/llds_out_file.m:
compiler/mercury_compile_llds_back_end.m:
compiler/ml_accurate_gc.m:
compiler/ml_args_util.m:
compiler/mode_errors.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/old_type_constraints.m:
compiler/optimize.m:
compiler/polymorphism.m:
compiler/polymorphism_goal.m:
compiler/post_typecheck.m:
compiler/pre_typecheck.m:
compiler/pred_table.m:
compiler/proc_gen.m:
compiler/rbmm.region_transformation.m:
compiler/recompilation.usage.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/simplify_goal_call.m:
compiler/ssdebug.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_constr_initial.m:
compiler/termination.m:
compiler/trailing_analysis.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_class_info.m:
compiler/typecheck.m:
compiler/typecheck_error_undef.m:
compiler/types_into_modes.m:
compiler/xml_documentation.m:
    Conform to the changes above.

compiler/recompilation.m:
    Add a note.

compiler/parse_tree_out_sym_name.m:
    Improve variable names.

tests/invalid/external2.err_exp:
    Expect the fixed arity in an error message.

tests/invalid/gh72_errors.err_exp:
    Expect the expanded text of an error message.
2023-07-03 01:57:10 +02:00
Zoltan Somogyi
f6e5a438c4 Allow underscores before exponents in floats.
library/mercury_term_lexer.m:
    As above.

NEWS.md:
    Announce the change.

doc/reference_manual.texi:
    Document the change.

tests/hard_coded/parse_number_from_string.exp:
tests/invalid_nodepend/invalid_float_literal.err_exp:
    Update these expected outputs after the change.
2023-07-02 02:20:39 +02:00
Julien Fischer
d0b64c87c7 Ignore files generated by MSVC.
*/.gitignore:
   Ignore any increment linker files (.ilk) and program database (.pdb)
   file that MSVC generates.
2023-07-01 02:25:53 +10:00
Zoltan Somogyi
7292ecb571 Don't generate duplicate instance declarations.
We used to include in the .int0 file the abstract form of all the instance
declarations in both the interface and the implementation sections.
When an instance is declared (in an already-abstract form) in the interface
section and defined in the implementation section, this resulted in the
abstract interface declaration being included in the .int0 file twice,
once in the interface section, and once in the implementation section.

compiler/comp_unit_interface.m:
    Fix this by including an abstract instance declaration in the
    implementation section of a .int0 file only if it does not also appear
    in the interface section.

    Conform to the changes in prog_item.m below.

compiler/parse_tree_out.m:
    To help implement the above test, add a function to return the string
    form of an abstract instance declaration.

    It is easy to make this change for *abstract* instance declarations,
    but not *concrete* instance definitions, because (in order to handle
    instances that define methods by clauses, instead of by pred/func names)
    the latter would require generalizing *all* the code for writing out
    clauses, with all the overhead associated with replacing first order calls
    with method calls.

    Another change (unrelated to the problem above) is to write out
    typeclass and instance definitions for typeclasses with no methods
    in a nicer form. Instead of looking like this:

        :- instance classname(argtypes) where [

        ].

    they now look like this:

        :- instance classname(argtypes) where [].

    Another formatting change unrelated to the above: don't put parentheses
    around typeclass names in instance declarations/definitions if the name
    is all alphanumeric and not an operator.

    Conform to the changes in prog_item.m below.

compiler/prog_data.m:
compiler/prog_item.m:
    To be able to use the new code to convert abstract instances to strings
    in comp_unit_interface, and to write out abstract instance declarations
    inside .int0 (and other .intN) files, it helps to know which instance
    items can only be abstract in these files. As it turns out, none can be
    concrete. So define a subtype of item_instance_info that can contain
    only abstract instance declarations, and use it to replace
    item_instance_info in parse_tree_intN for all N.

compiler/parse_tree_out_info.m:
    Add a utility function for new code in comp_unit_interface.m
    invoking new code in parse_tree_out.m.

compiler/convert_parse_tree.m:
    Conform to the changes in prog_item.m by insisting that instances
    read in from .intN files are all abstract.

    Fix some typos in some error messages (which people can see only if
    something has screwed up a .intN file).

compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/recompilation.version.m:
    Conform to the changes above.

compiler/intermod.m:
    Simplify some code.

tests/invalid/Mercury.options:
    Fix the failure of the instances_pc.instances_pc_helper_1 test case
    when intermodule optimization is enabled for a bootcheck by disabling
    intermodule optimization for this test. The old code to do so didn't
    work due to typos.

tests/invalid/instances_pc.instances_pc_helper_1.err_exp:
    Expect a reference to only ONE old instance declaration in
    instances_pc.int0. Expect it at a new line number, due to the first
    formatting change above.

tests/misc_tests/pretty_print_test.exp:
    Expect no unnecessary parentheses around a class name in an
    instance definition, due to the second formatting change.
2023-06-30 09:34:01 +02:00
Julien Fischer
3e020479ec Fix typo.
test/hard_coded/Mercury.options:
    As above.
2023-06-24 14:46:23 +10:00
Julien Fischer
403d9c4e3d Add XXXs about some test failures with MSVC.
tests/hard_coded/Mercury.options:
    As above.
2023-06-24 14:21:42 +10:00
Zoltan Somogyi
d03f200889 Add missing import. 2023-06-23 12:14:36 +02:00
Zoltan Somogyi
a5f9cb6851 Reduce differences between interpreter.m versions.
extras/trailed_update/samples/interpreter.m:
samples/interpreter.m:
    We have these two different versions of a pure Prolog interpreter
    as examples of Mercury code. Reduce the number of unneeded points
    of difference between them, by copying the better code at each such point
    to the other file.

tests/debugger/interpreter.m:
    This file is automatically copied from samples/interpreter.m.

tests/debugger/interpreter.exp:
    Expect the changes caused by the update to the source file.
2023-06-22 14:54:59 +02:00
Zoltan Somogyi
81b4c3272e Stop using digraph.tsort and digraph.atsort ...
... and start using their more descriptively-named synonyms.

In some cases, instead of getting and then reversing a list of sccs,
ask for the sccs in the needed order in the first place.

compiler/dependency_graph.m:
compiler/generate_dep_d_files.m:
compiler/make.program_target.m:
compiler/mlds_to_java_global.m:
compiler/mode_ordering.m:
compiler/rtti_to_mlds.m:
compiler/stratify.m:
    As above.

compiler/prog_event.m:
    As above.

    Address an old and now-inaccurate XXX. When a synthesized attribute
    depends on its value, either directly or through the values of other
    synthesized attributes, include the names of the attributes involved
    in the error message, instead of just saying that there is circular
    dependency *somewhere* among the attributes.

tests/invalid/synth_attr_error.err_exp:
    Expect the updated, more specific error messages.

tests/invalid/Mmakefile:
    Enable the synth_attr_error test case, which wasn't enabled before
    (though it does have an entry in Mercury.options.)

tests/invalid/invalid_event_spec:
tests/invalid/syntax_error_event_spec:
tests/invalid/synth_attr_error_spec:
    Replace tabs with spaces.
2023-06-22 00:25:26 +02:00
Zoltan Somogyi
eb6617c175 Rename X's aux modules as X_helper_N in submodules.
tests/submodules/*.m:
    Rename modules as mentioned above.

    Indent nested submodules to make them stand out.

    Group foreign_procs by what predicate they implement, not by
    their implementation language.

tests/submodules/*.m:
tests/submodules/*.err_exp:
tests/submodules/Mmakefile:
tests/submodules/Mercury.options:
    Update all references to the moved modules.
2023-06-19 22:16:36 +02:00
Zoltan Somogyi
df344578d3 Rename X's aux modules as X_helper_N in invalid_submodules.
tests/invalid_submodules/*.m:
    Rename modules as mentioned above.

    Indent nested submodules to make them stand out.

tests/invalid_submodules/*.m:
tests/invalid_submodules/*.err_exp:
    Update all references to the moved modules.

tests/invalid_submodules/Mercury.options:
    Delete reference to a test that is another directory.
2023-06-19 18:31:32 +02:00
Zoltan Somogyi
d4e7cde83e Update tests/invalid_purity/purity.m. 2023-06-19 10:33:26 +02:00
Zoltan Somogyi
5b3e59a8f8 Fix test directory list rot. 2023-06-19 01:15:54 +02:00
Zoltan Somogyi
adac4e462b Fix (inconsequential) bad module name. 2023-06-19 01:15:32 +02:00
Zoltan Somogyi
ac57c2f70d Improve diagnostics for malformed number literals.
library/mercury_term_lexer.m:
    Make the diagnostics for malformed numbers more detailed, and thus
    more easily understandable.

tests/hard_coded/parse_number_from_string.exp:
tests/invalid_nodepend/invalid_binary_literal.err_exp:
tests/invalid_nodepend/invalid_decimal_literal.err_exp:
tests/invalid_nodepend/invalid_float_literal.err_exp:
tests/invalid_nodepend/invalid_hex_literal.err_exp:
tests/invalid_nodepend/invalid_octal_literal.err_exp:
    Update the expected error messages.
2023-06-19 01:10:19 +02:00
Zoltan Somogyi
9a699b3d12 Fix redundant undefined inst error.
The invalid_nodepend/bad_mutable test case got two different error messages
for the same error: an undefined inst in a mutable. Fix this by not generating
the error message in add_mutable_aux_preds.m if module_qual
the details of its wording).

compiler/module_qual.m:
    Replace the mq_sub_info fields that were flags saying *whether*
    we have found any undefined types, insts, modes or typeclasses,
    with sets saying *which* undefined types, insts, modes or typeclasses
    we have found references to. Add an mq_id arg to mq_info_record_undef_mq_id
    to make this possible.

    These sets are expected to be very small, so it does not matter
    which of our several set implementations we use for them. But for some
    other fields of the same structure, it does matter, so use a set
    implementation with better complexity results for them, and then
    use the same set implementation for the changed fields as well,
    for simplicity.

compiler/make_hlds_passes.m:
    Conform to the changes in module_qual.m, and pass the newly-recorded
    set of undefined insts to the code that checks (and implements) mutables
    in add_mutable_aux_preds.m.

compiler/prog_mutable.m:
    Add the set of undefined insts to the data structure that
    add_mutable_aux_preds threads through its predicates. (It is here
    because its main job is to provide info to add_mutable_aux_preds's
    subcontractors in this module.)

compiler/add_mutable_aux_preds.m:
    Don't generate an error message for an undefined inst that has already
    had an error message generated for it.

compiler/mercury_compile_make_hlds.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.id_set.m:
compiler/module_qual.qual_errors.m:
compiler/module_qual.qualify_items.m:
    Conform to the changes in module_qual.m.

tests/invalid_nodepend/bad_mutable.err_exp:
    Expect one error message for the undefined inst, not two.

tests/invalid_nodepend/bad_mutable.m:
    Delete the comment about the second error message being redundant,
    since now there IS no second error message.
2023-06-18 20:08:09 +02:00
Julien Fischer
ca9d9850e0 Fix the failure of general/read_dir_regression on Windows.
tests/general/read_dir_regression.m:
tests/general/read_dir_regression.exp4:
     Add an expected output for this test on Windows.
2023-06-18 23:14:48 +10:00
Julien Fischer
c14af1428e Fix the failure of hard_coded/special_char on Windows.
tests/hard_coded/special_char.m:
tests/hard_coded/special_char.exp2:
    Add an additional expected output for systems that use
    CRLF line endings.
2023-06-18 23:08:13 +10:00
Zoltan Somogyi
41bb773f6d Rename some test modules with "keyword" names.
Add the previously-missing part of the diff.
2023-06-18 14:59:38 +02:00
Zoltan Somogyi
83b118d7f0 Rename some test modules with "keyword" names.
tests/invalid_nodepend/*.m:
    Rename modules as mentioned above.

    Also rename a module with an out-of-sequence number.

    Update all references to the moved modules.

    Add some missing lines around vim modelines.

tests/invalid_nodepend/*.err_exp:
    Update all references to the moved modules and/or moved lines.

tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
    Update all references to the moved modules.
2023-06-18 14:56:19 +02:00
Zoltan Somogyi
db6b532456 Rename X's aux modules as X_helper_N in invalid_manual.
tests/invalid/*.m:
    Rename modules as mentioned above.

    Update all references to the moved modules.
2023-06-18 12:54:19 +02:00
Zoltan Somogyi
f15a2b5f2a Rename X's aux modules as X_helper_N in invalid_make_int.
tests/invalid/*.m:
    Rename modules as mentioned above.

    Update all references to the moved modules.

tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
    Update all references to the moved modules.
2023-06-18 12:51:04 +02:00
Zoltan Somogyi
f345d20e33 Rename X's aux modules as X_helper_N in invalid.
tests/invalid/*.m:
    Rename modules as mentioned above.

    In two cases where the main module name is a Mercury keyword (to the
    extent that Mercury has keywords), add a "test_" prefix to the
    module name.

    Reorganize the ho_default_func_2 test case. The original code
    of this test had three modules, a parent and two children,
    with the module being tested being one of the *child* modules
    (ho_default_func_2.sub). This does not work; the .log file
    from the successful execution of this test case showed that
    there was no actual compilation involved; the test stopped
    after invoking "mmc --generate-dependencies" on that child module.
    The new version of this test makes that child module the main module,
    and moves the relevant parts of the other two original modules
    into a single new child module.

    Rename ii_parent to instance_pc (pc being short for parent-child).
    This test case still has the child module listed as the target
    in Mmakefile, so it still does not progress past generating its
    dependencies.

    Rename the imported_mode test case as bad_exported_mode,
    because this is what it was testing.

    exported_mode.m was used both as the main module of a test,
    and as a helper module in the imported_mode test (now renamed
    to bad_exported_mode). Make a copy of it as a helper module
    for bad_exported_mode.

    Update all references to the moved modules.

    General updates to programming style, such as

    - replacing DCG notation with state var notation
    - adding lines around vim modelines
    - fixing indentation
    - fixing grammar errors in comments

tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
    Update all references to the moved modules and/or moved lines.
2023-06-16 20:18:36 +02:00
Zoltan Somogyi
2bd7c5ee3e Rename X's aux modules as X_helper_N in hard_coded.
tests/hard_coded/*.m:
    Rename modules as mentioned above.

    In a few cases, where the main module's name itself had a suffix,
    such as "_mod_a" or "_main", remove that suffix. This entails
    renaming the .exp file as well. (In some cases, this meant that
    the name of a helper module was "taken over" by the main module
    of the test case.)

    Update all references to the moved modules.

    General updates to programming style, such as

    - replacing DCG notation with state var notation
    - replacing (C->T;E) with (if C then T else E)
    - moving pred/func declarations to just before their code
    - replacing io.write/io.nl sequences with io.write_line
    - replacing io.print/io.nl sequences with io.print_line
    - fixing too-long lines
    - fixing grammar errors in comments

tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
    Update all references to the moved modules.

    Enable the constant_prop_int test case. The fact that it wasn't enabled
    before is probably an accident. (When constant_prop_int.m was created,
    the test case was added to a list in the Mmakefile, but that list
    was later removed due to never being referenced.)

tests/hard_coded/constant_prop_int.{m,exp}:
    Delete the calls to shift operations with negative shift amounts,
    since we have added a compile-time error for these since the test
    was originally created.
2023-06-16 08:33:22 +02:00
Zoltan Somogyi
5207af16a1 Add tests/warning/missing_singleton_warning.exp.
It should have been added when the test case was enabled.
2023-06-10 22:38:13 +02:00
Zoltan Somogyi
4daaa739ef Delete tests/warning/trace_goal_dupl_defn.m.
It was never enabled. It was intended to test the warnings/errors you get
when you use the same variables in more than one trace goal. However,
since 2017, when compiler/pre_quantification.m was added, any such variables
automatically get renamed apart, which means that there never will be
any warning or error messages generated for them.

There is no need for this test case as a test of *not* getting any
warnings or errors, because hard_coded/dup_vars_in_trace_scopes_only.m
does that job just fine, and its code is very similar to the code
of trace_goal_dupl_defn.m.
2023-06-10 10:16:02 +02:00
Zoltan Somogyi
783f4b2be4 Fix singleton warnings for code with 'some [...]' goals.
The code in make_hlds_warn.m that is intended to generate singleton warnings
hasn't ever been able to handle code containing 'some [...]' goals properly.
The reason is that

- add_clause.m invokes make_hlds_warn.m only *after* it does quantification
  on the body of the clause being added to the HLDS, but

- quantification has always replaced all lists of quantified variables
  with the empty list.

This meant that

- we never could report code in which the only occurrence of a variable
  was in a list of quantified variables, which is something we *should*
  warn about, and

- we always did generate a singleton warning for code such as
  "some [Val] map.search(Map, Key, Val)", which is something we *should not*
  warn about.

This diff fixes this problem.

The main change is a mechanism that allows us to tell quantification.m
to keep lists of quantified variables intact. However, since the rest
of the compiler does not react well to these lists not being empty,
this diff

- gets make_hlds_warn.m to report whether the clause body goal, in which
  quantification.m was told to preserve any lists of quantified variables,
  *actually contained* any nonempty lists of quantified variables, and

- if it did, then we invoke quantification.m again, this time telling it
  to nuke all lists of quantified variables.

This nuking has to be done relatively rarely, because only a very small
fraction of clauses contain any explicit quantification.

(An alternative design would be for make_hlds_warn.m to always nuke
any nonempty list of quantified variables it traversed. However, this would
require *always* rebuilding the clause body goal, which would probably
be slower on average.)

The above is the main change in this diff. However, the change that is
responsible for the bulk of the diff is the addition of a flag to
exist_quant scopes to specify whether that scope was created by the user
or by the compiler. This is needed because if make_hlds_warn.m sees code
such as "some [Val] map.search(Map, Key, Val)", it definitely *should*
generate a warning about Val being singleton (if it does not occur outside
this code) if the "some [Val]" scope was put there by the compiler.

compiler/make_hlds_warn.m:
    Treat user-generated exist_quant scopes as before (the old code did
    the right thing to generate warnings, it was just given wrong inputs).
    Treat compiler-generated exist_quant scopes as if they weren't there,
    for warning-generating purposes.

    To make this distinction possible, use separate code to handle
    exist_quant and promise_solutions scopes.

    Record whether the goal traversal has seen any nonempty lists of quantified
    variables, and return this info to the caller in add_clause.m.

    Encode the nonempty nature of a list in the argument structure of a
    predicate.

    Update some obsolete terminology in variable and field names.

    Clarify the logic of some code.

compiler/quantification.m:
    Add the keep_quant/do_not_keep_quant switch described above.

    Add some documentation of the predicates to which it is applicable.

    Add free_goal_expr_vars, a version of free_goal_vars that takes
    only a goal expr, without the goal info. At one point, I thought
    this diff needed it. It does not, so the new function is not used,
    but there is also not much point in deleting it, Simplify the code
    of free_goal_vars, deleting one of its callees after inlining it
    at its only call site.

    Replace a appended-to-at-the-front-and-then-reversed list with a cord.

compiler/hlds_goal.m:
    Add the created-by-user-or-compiler flag to exist_quant scopes.

compiler/add_clause.m:
    Move the code that invokes make_hlds_warn.m to warn about singletons
    into the clauses_info_add_clause predicate, whose subcontractor
    add_clause_transform does the initial quantification. The reason
    for this move is that we have never generated singleton variable warnings
    for clauses that were read in from .opt files, or for clauses which are
    known to have syntax errors. With the new setup, if we such clauses,
    clauses_info_add_clause can, and does, tell add_clause_transform
    to tell quantification.m to nuke lists of quantified variable
    right away. It is only for the clauses we *can* warn about
    that clauses_info_add_clause will tell add_clause_transform
    to keep those variables, and will then itself invoke the code
    in make_hlds_warn.m that warns about singletons, followed, if needed,
    by a var-list-nuking reinvocation of quantification.

    This centralization of the code relevant to warning code in
    clauses_info_add_clause also allows the deletion of several of its
    output arguments, since its two callers used those arguments
    only to invoke the warning-generation code. It also eliminates
    the duplication of code in those two callers.

compiler/instance_method_clauses.m:
    Conform to the change in add_clause.m.

compiler/add_foreign_proc.m:
compiler/assertion.m:
compiler/constraint.m:
compiler/cse_detection.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/format_call.m:
compiler/goal_expr_to_goal.m:
compiler/goal_util.m:
compiler/hlds_desc.m:
compiler/hlds_out_goal.m:
compiler/interval.m:
compiler/lambda.m:
compiler/mark_tail_calls.m:
compiler/ml_code_gen.m:
compiler/mode_constraints.m:
compiler/modecheck_goal.m:
compiler/polymorphism_goal.m:
compiler/pre_quantification.m:
compiler/purity.m:
compiler/saved_vars.m:
compiler/simplify_goal_scope.m:
compiler/simplify_proc.m:
compiler/state_var.m:
compiler/stm_expand.m:
compiler/superhomogeneous.m:
compiler/switch_detection.m:
compiler/try_expand.m:
compiler/typecheck.m:
compiler/unique_modes.m:
    Conform to the change in hlds_goal.m and/or quantification.m.

compiler/options.m:
    Add a way to detect the presence of this fix in the installed compiler.

tests/valid/Mmakefile:
    Enable the old test case for this problem, some_singleton,
    which we haven't passed until now.

tests/warnings/Mmakefile:
    Enable the missing_singleton_warning test case, which we haven't passed
    until now.
2023-06-10 09:59:00 +02:00
Zoltan Somogyi
16b964be81 Improve warnings about unbound type variables.
compiler/post_typecheck.m:
    Do not generate warnings abouts unbound type variables in code
    that is not in the current module.

    If all the variables we are generating a report for have types
    that are *just* type variables, then report just the names
    of the variables; the names of the associated type variables
    are just clutter in that case (especially when those type variables
    are compiler-generated).

    If some of the variables we are generating a report for have types
    that are not just type variables (which can happen when the type is
    e.g. list(T)), then report the type of each variable as before,
    but try to line things up so that all the types start in the same column.
    This should make the message easier to read.

    In both cases, sort the list of variables on their names.

    Update the wording of the warning to accommodate the changes above,
    and to expand contractions.

tests/invalid/bad_sv_unify_msg.err_exp:
tests/invalid/bug257.err_exp:
tests/invalid/coerce_void.err_exp:
tests/invalid/freefree.err_exp:
tests/invalid/typeclass_test_8.err_exp:
tests/invalid/unsatisfiable_constraint.err_exp:
tests/warnings/singleton_test.exp:
tests/warnings/singleton_test.exp2:
tests/warnings/singleton_test.exp3:
    Expect the updated warning text.
2023-06-08 18:58:06 +02:00
Julien Fischer
2a366cf295 Deprecate --no-ansi and --no-ansi-c.
--no-ansi (mgnuc) and --no-ansi-c (mmc) have not actually done anything for
many years now. Deprecate these options and remove their "use" throughout most
of the Mercury system. (The remaining uses are in the Makefiles for the Boehm
GC, which need to be updated separately.)

Also deprecate the internal compiler option --cflags-for-ansi.

compiler/options.m:
    Document that --no-ansi-c is now deprecated.

    Document that the internal option --cflags-for-ansi is now
    deprecated.

compiler/compile_target_code.m:
    Do not pass the ANSI options to the C compiler.

scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
    Deprecate the --no-ansi option; delete code that no longer does
    anything useful.

configure.ac:
    Delete the configuration variable CFLAGS_FOR_ANSI; it is only ever
    set to be empty. (The comment talks about --no-ansi doing other things
    in the mgnuc script. It used to also cause some preprocessor macros
    to be defined for compatibility with the system headers on some
    platforms -- that has not been the case since 2013.)

doc/user_guide.texi:
    Document that --no-ansi-c is deprecated.

bytecode/Mmakefile:
compiler/Mercury.options:
library/Mercury.options:
extras/odbc/odbc.m:
runtime/Mmakefile:
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
tests/hard_coded/Mercury.options:
tests/valid/Mercury.options:
trace/Mmakefile:
util/Mmakefile:
    Conform to the above change.

NEWS.md:
    Announce the above.
2023-05-31 17:44:26 +10:00
Zoltan Somogyi
d769b04a96 Base string.format_table{,_max} on common code.
library/string.m:
    Even though format_table_max is a minor tweak on format_table,
    its implementation used to be completely separate. Act on an old XXX
    and make format_table use the same primitive ops as format_table_max.

    Document the operation of format_table a bit better.

    Change the way that format_table_max handles column-width limits,
    by accepting overlong column contents *without* starting a new line.
    Document the new semantics.

    Use predmode decls when possible.

tests/general/string_test.{m,exp}:
    Add a test of format_table_max, which previously did not have one.
2023-05-22 19:23:37 +10:00
Zoltan Somogyi
9364d4cbc5 Replace tables with spaces. 2023-05-02 02:25:38 +10:00
Zoltan Somogyi
3364b69e34 Simplify a test. 2023-05-02 02:22:46 +10:00
Zoltan Somogyi
b2ab9f8711 Wrap the test term in angle brackets.
tests/hard_coded/write_binary.{m,exp}:
    Wrap the test term in angle brackets, in order to make the presence
    of spaces, tabs and newlines apparent.
2023-04-27 21:27:21 +10:00
Zoltan Somogyi
810d95a7ea Update the hard_coded/write_binary test case.
tests/hard_coded/write_binary.m:
    Print the term whose write-out-and-read-back is being tested
    before the test, not after. Print the result of the test after this.

    If the test succeeds, don't print the term out again.

    Put blank lines between different kinds of tests, and between
    tests of different terms.

    Return error messages as strings, rather than as exceptions,
    where possible.

    Make the diagnostic for "read back term differs from original"
    more useful for debugging write_binary/read_binary.

    Put the declaration of a predicate just before the predicate.

tests/hard_coded/write_binary.exp:
    Expect the updated output.
2023-04-27 21:19:51 +10:00
Zoltan Somogyi
4281a28f73 Make text_{input,output}_stream standalone types ...
... and make {input,output}_stream synonyms for them, rather than vice versa.

library/io.m:
    As above.

library/bitmap.m:
library/dir.m:
library/io.primitives_read.m:
library/io.stream_db.m:
library/io.text_read.m:
library/mercury_term_lexer.m:
library/stream.string_writer.m:
    Conform to the change above.

tests/hard_coded/stream_string_writer_types.exp:
    Expect the new type_ctor for text streams.
2023-04-24 13:52:10 +10:00
Zoltan Somogyi
00e1a62ab4 Fix a misleading error message.
compiler/det_report.m:
    In some cases described in the new test case, the error message
    we print for a missing switch inside an arm of a larger switch
    is misleading unless we print *which* arm of the larger switch
    we are complaining about, so print that information.

tests/invalid/require_complete_nested_switch.{m,err_exp}:
    A test case derived from the real-life error that motivated this diff.

tests/invalid/Mmakefile:
    Enable the new test case.
2023-04-19 19:57:51 +10:00
Zoltan Somogyi
713d541ada Small improvements in the code simplifying calls.
compiler/const_prop.m:
    Replace pairs and maybes with a semantically meaningful type.
    Restrict this type to the part we actually use.

    Optimize ubits_per_{int,uint} the same way we have long optimized
    bits_per_{int,uint}.

compiler/simplify_goal_call.m:
    Improve the wording of some warnings.

    When constructing those warnings, don't test the value of warn_simple_code
    twice.

compiler/uint_emu.m:
    Fix copy-and-paste typo.

tests/warnings/unsigned_zero_cmp.exp:
    Expect the updated text of the above warnings.
2023-04-17 17:35:25 +10:00
Zoltan Somogyi
1ca63c2867 Run string_format_{bad,unknown} in profdeep grades.
tests/invalid/Mmakefile:
    These tests have not needed to catch exceptions in a long time,
    so there is no need to avoid running them in profdeep grades.
2023-03-19 14:10:29 +11:00
Zoltan Somogyi
2c866fb4d2 Avoid "overriding recipe" messages in tests/invalid.
tests/invalid/Mmakefile:
    Some tests cases in this directory have target-specific make rules
    if (and only if) the test flags include --intermod-opt. We used to include
    these tests in the lists of tests that do not have target-specific rules,
    which lead to messages about "overriding recipe for <target>" from make.
    Fix this by including test cases in the list of tests that do not have
    target-specific rules only if they belong there.

    Delete inappropriate entries from  REDIRECT_OPT_ERROR_MODULES, the list
    of tests cases that have target-specific make rules if (and only if)
    the test flags include --intermod-opt. Some of the modules that used
    to be in this list have since been moved to the invalid_make_int directory,
    where they don't need special handling (because what is special here
    is standard there). Some other modules in this list either never existed
    or have been deleted from the test suite as a whole. Delete both of these
    kinds of test case names from that list.

    Move the rules that figure out whether to enable a category of tests
    (e.g. the trailed tests) just after the definition of the list of tests
    in that category.

    Delete an obsolete comment, whose up-to-date form has been nearby
    for a while now.

    Add an XXX.

tests/invalid_make_int/Mmakefile:
    Note which test cases that have been moved here were included in
    REDIRECT_OPT_ERROR_MODULES, in case that does turn out to be useful later.
2023-03-19 02:49:22 +11:00
Zoltan Somogyi
40ff19acbb Standardize mode names in argument lists.
compiler/hlds_error_util.m:
    When converting lists of arguments mode to strings for error messages,
    replace from/to pairs of insts that stand for standard modes with the
    names of those standard modes.

compiler/prog_mode.m:
    Add a utility function for doing that standardization.

tests/invalid/io_in_ite_cond.err_exp:
tests/invalid_manual/gh118.err_exp:
    Expect the standard forms of modes.

tests/invalid_manual/Mmakefile:
    Specify the grade for the test independently of the grade of the
    workspace or of the last bootcheck. Make the Mercury compiler flags
    specific to the test.
2023-03-19 00:24:25 +11:00
Zoltan Somogyi
d9046a19d2 Add a test case for github issue #118.
tests/invalid_manual/gh118.err_exp:
tests/invalid_manual/gh118.gh118_helper.m:
tests/invalid_manual/gh118.m:
    As above. The invalid_manual directory is a new test directory.
    Its tests are not executed by tools/bootcheck.

tests/invalid_manual/Mmakefile:
    Add a make rule for executing the test.

tests/invalid_manual/Mercury.options:
    Add this options file (currently empty).

compiler/det_report.m:
    Redirect comments to the actual location of the test case.
2023-03-18 21:33:54 +11:00