25234 Commits

Author SHA1 Message Date
Zoltan Somogyi
a5fb3550e3 Add missing imports. 2026-03-07 04:03:14 +11:00
Zoltan Somogyi
0fb9165ac3 Fix typo. 2026-03-07 00:32:26 +11:00
Julien Fischer
030a61258e Use HTTPS versions of some web links.
library/calendar.m:
    As above.
2026-03-06 22:17:19 +11:00
Julien Fischer
ca24a4b930 Improve variable naming in init_duration/7.
library/calendar.m:
    As above.
2026-03-06 21:15:05 +11:00
Zoltan Somogyi
7ba838bbad Move the to_int predicates into the standard library.
tests/hard_coded/truncate_to_int.m:
    Delete the {int64,uint64,uint32}_to_int predicates, and ...

library/int64.m:
library/uint32.m:
library/uint64.m:
    ... move them to these modules, where they always were intended to go.
    Add proper comments describing them.

    In the case of int64.m, it already had a to_int predicate doing a checked
    conversion. Replace its definition with the one from truncate_to_int.m,
    because it should never be slower, and should be faster on some platforms.

    Add det function versions of the new predicates, which abort
    instead of failing.

NEWS.md:
    Announce the new predicates.
2026-03-06 20:32:20 +11:00
Julien Fischer
26c619723f Fix typo.
tests/hard_coded/truncate_to_int.m:
    As above.
2026-03-06 16:31:43 +11:00
Julien Fischer
a8896400d6 Add Java and C# implementations of the truncate to int operations.
tests/hard_coded/truncate_to_int.m:
    As above.
2026-03-06 16:24:47 +11:00
Zoltan Somogyi
71b4de934a Allow TEST_FAILS_DIR to be set by an environment var. 2026-03-06 05:38:56 +11:00
Zoltan Somogyi
801b2efbac Add prototypes for operations that truncate to int.
tests/hard_coded/truncate_to_int.m:
    Add this test case to test operations that convert int64s, uint64s
    and uint32s to ints *safely*.

    For now, these conversions are implemented only for C. Until they
    have Java and C# definitions as well, they are defined here.

tests/hard_coded/truncate_to_int.exp:
tests/hard_coded/truncate_to_int.exp2:
    Expected outputs on 64 and 32 bit platforms.

tests/hard_coded/Mmakefile:
    Enable the new case. For now, it will fail in non-C grades.
2026-03-06 05:38:09 +11:00
Julien Fischer
a194e47c33 Add clamp/3 for other primitive integer types.
library/int.m:
library/int{8,16,64}.m:
library/uint.m:
library/uint(8,16,32,64}.m:
    Add the new function.

NEWS.md:
    Announce the additions.

tests/hard_coded/Mmakefile:
tests/hard_coded/clamp_int*.{m,exp}:
tests/hard_coded/clamp_uint*.{m,exp}:
    Add tests for the new functions.

tests/hard_coded/string_code_point.m:
    Avoid an ambiguity due to this module defining its own version of clamp/3.
    XXX we should replace the local one with a call to int.clamp/3, but this
    module constructs ranges where Max < Min and aborts with the new one.
2026-03-05 16:54:47 +11:00
Zoltan Somogyi
1df6d88d3b Improve predicate comments. 2026-03-05 02:31:57 +11:00
Zoltan Somogyi
cb2beb88c1 Delete a ZZZs. 2026-03-04 20:08:33 +11:00
Zoltan Somogyi
a7159fa88f Give some variables more consistent names. 2026-03-04 20:07:22 +11:00
Zoltan Somogyi
b261c5fcb2 Enable dense switches on sized and unsigned ints.
Until now, the only integer type we generated dense switches
(including lookup switches) for was int itself; we did not do so
for any sized and/or unsigned integer types.

compiler/switch_util.m:
    Simplify the representation of whether a switch is on an integer type.
    The new version makes it impossible to make the mistake that caused
    bug582 in the first place: not having a single representation for
    for the switch being on *any* kind of integer type.

    This fix requires solving a problem we never had to solve before:
    representing information such as the min and max case values
    in a way that works for every integer type, signed or unsigned,
    sized or not. The solution that this diff adopts is to use int32s
    to represent those limits, which implies that whatever the type
    of the integer value being switched on, we will generate a dense
    or a lookup switch for it only if all case values fit into an int32.
    Since case values over two billion are vanishingly rare, this should be
    an acceptable restriction.

    Use uints instead of ints to represent counts of things.

    Delete an unneeded pair of arguments.

compiler/lookup_switch_util.m:
    Conform to the changes in switch_util.m. Use some of the new types
    there to make arguments in arguments lists less confusable.

    Provide some new utility operations.

    Add XXXs where the basic operations we need seem not to exist.

compiler/dense_switch.m:
compiler/lookup_switch.m:
    Use the new types in switch_util.m that can represent switches
    on any integer type.

compiler/ml_lookup_switch.m:
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/switch_gen.m:
    Conform to the changes above, and thereby gain the ability
    to generate switches on integer types other than int itself.

library/int64.m:
    Add a (commmented-out) declaration of an operation that could
    help resolve one of the issues in new code in the modules above.
    Similar operations would be needed in the modules of other
    sized integer types as well.

library/library.m:
    Fix a typo.

tests/hard_coded/bug582.{m,exp}:
    Add a test case for this issue. Note that while we test whether
    we get the expected output, there is no simple automatic way
    to detect whether it was generated using a lookup table.

tests/hard_coded/Mmakefile:
    Enable the new test case.
2026-03-04 19:51:35 +11:00
Julien Fischer
aa788cc057 Address a review comment.
library/int32.m:
    Use a more direct, if more verbose, definition for clamp/3.
2026-03-04 18:41:25 +11:00
Julien Fischer
be5e019a33 Add int32.clamp/3.
library/int32.m:
    Add the new function.

NEWS.md:
    As above.

tests/hard_coded/Mmakefile:
tests/hard_coded/clamp_int32.{m,exp}:
    Add a test for the new function.
2026-03-04 13:24:30 +11:00
Julien Fischer
8f71e926d9 Extend fixed-size int tests to cover min/2 and max/2.
tests/hard_coded/arith_int{8,16,32,64}.{m,exp}:
tests/hard_coded/arith_uint{8,16,32,64}.{m,exp}:
    As above.
2026-03-04 01:07:28 +11:00
Zoltan Somogyi
d0681be57a Factor out duplicate code. 2026-03-03 23:49:58 +11:00
Julien Fischer
33524a66a1 Fix map.union_list/4 documentation.
library/map.m:
    As above.
2026-03-03 13:01:00 +11:00
Julien Fischer
d935b4fa60 More fixes for list module documentation.
library/list.m:
      Refer to a parameter by its correct name in the documentation of merge.

      Add missing blank comments.

      Fix capitalization in some spots.
2026-03-03 10:40:03 +11:00
Julien Fischer
043a94a3fb Fix documentation of list.merge_lists_and_remove_dups.
library/list.m:
    Adjust my previous fix to the documentation of list.merge_lists.

    Fix the documentation of merge_lists_and_remove_dups, which had
    the same error as merge_lists.
2026-03-03 10:31:51 +11:00
Julien Fischer
6f9eeb00d9 Fix error in documentation of list.merge_lists.
library/list.m:
     Fix a spot where documentation of merge_lists is actually
     that of merge.
2026-03-03 10:27:20 +11:00
Zoltan Somogyi
acef703a48 Do not export a predicate unnecessarily. 2026-03-03 05:13:49 +11:00
Zoltan Somogyi
93fcad53fc Improve documentation. 2026-03-03 05:12:21 +11:00
Julien Fischer
0e01994d07 Fix documentation of list.take* predicates.
library/list.m:
    Fix paramter name inconsistency.
2026-03-02 17:29:12 +11:00
Julien Fischer
5ddb6d201a Minor fixes for README files.
Documentation/README.MS-Windows.md:
Documentation/README.cross.md:
Documentation/README.macOS.md:
    As above
2026-03-02 17:21:40 +11:00
Julien Fischer
c0a628a49d Fix minor errors the MSVC README.
Documentation/README.MS-VisualC.md:
    As above.
2026-03-02 17:06:21 +11:00
Julien Fischer
7edc166a8f Fix minor errors the MSYS2 README.
Documentation/README.MSYS2.md:
    As above.
2026-03-02 17:01:18 +11:00
Julien Fischer
9307494ff7 Add missing long option to cowsay sample.
samples/mcowsay.m:
     As above.
2026-03-02 16:06:20 +11:00
Zoltan Somogyi
10565df4f6 Break up a large predicate. 2026-03-02 05:19:45 +11:00
Zoltan Somogyi
85876a9ecc Split equiv_type.m into two parts.
The old equiv_type.m's growth was organic, not planned. It mixed predicates
operating on different levels, and even predicates on the same level
were not always logically organized.

compiler/equiv_type_parse_tree.m:
    This module contains the bulk of the old equiv_type.m, the part
    concerned with processing parse tree items and their major components.

compiler/equiv_type.m:
    The part of the old equiv_type.m that deals with expanding equivalences
    inside basic parts of program representations.

compiler/parse_tree.m:
compiler/notes/compiler_design.html:
    Include and document the new module.

compiler/decide_type_repn.m:
compiler/mercury_compile_make_hlds.m:
    Conform to the changes above.
2026-03-01 22:43:32 +11:00
Zoltan Somogyi
48a95366e1 Move a predicate to where it belongs. 2026-03-01 18:36:22 +11:00
Zoltan Somogyi
7d2146d3a9 Make items' recompilation dependencies more understandable.
compiler/recompilation.record_uses.m:
    Rename the eqv_expand_info type to item_recomp_deps to better document
    its purpose (it is to record which equivalence expansions *an item
    depends on*). Finish documenting the type itself.

    Rename the predicates operating on values of that type accordingly,
    together with the variables in their clauses.

    Since the point of the type is to record info about an item,
    make the main predicate that constructs values of this type
    take *the id the actual item* as input. Previously, it was just
    a sym_name that was part of the item id. We still need that version
    in two places (where we don't know the final item id yet), but use it
    only when we have to. In each case, document *why* we have to.

compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/qual_info.m:
compiler/add_pragma_type_spec.m:
    Conform to the changes above.

    Use a consistent naming scheme for the variables of the renamed type.

    In one case, stop using a "some [!StateVar]" scope that hurts
    readability more than it helps.
2026-03-01 18:35:38 +11:00
Zoltan Somogyi
c174ccfdb6 Fix too-long lines. 2026-03-01 16:00:56 +11:00
Zoltan Somogyi
5d804166da Pass all invariants parameters in one arg. 2026-02-28 23:47:25 +11:00
Zoltan Somogyi
7aa23d91d3 Fix indentation.
Stop duplicating the description of the library.
2026-02-28 20:01:06 +11:00
Zoltan Somogyi
94838a36d4 Add a test case for unused recursive args.
tests/warnings/unused_args_only_rec.{m,err_exp}:
    As above.

tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
    Enable the new test case with the right options.
2026-02-28 19:41:32 +11:00
Zoltan Somogyi
f197b229c9 Make debugging output more readable. 2026-02-28 19:40:24 +11:00
Julien Fischer
c7044148d9 Fix incorrect obsolete pragma.
library/getopt.m:
library/getopt_io.m:
    Fix an incorrect replacement named in an obsolete pragma.

NEWS.md:
    Fix incorrect arities in some entries.
2026-02-28 00:15:22 +11:00
Julien Fischer
27fd3be973 Delete unused imports.
extras/base64/base64.m:
    As above.
2026-02-27 23:41:33 +11:00
Julien Fischer
e480234798 Fix incorrect argument checks in mcurses.
extras/curses/mcurses.user.m:
    Fix some incorrect argument checks.
2026-02-27 23:33:30 +11:00
Julien Fischer
65f41d71b2 Fix some errors in extras/cgi.
extras/cgi/html.m:
    There is no HTML tag named "it", it is supposed to be "i".

    Fix a misformed attribute value.

    Fix incorrect character code character escapes.
2026-02-27 21:49:04 +11:00
Zoltan Somogyi
199c1a9cd1 Generate mode-specific unused args warnings if needed.
compiler/unused_args_warn_pragma.m:
    The existing code processed only the first procedure of each predicate,
    skipping all the later procedures. It had a comment saying that it
    warns about an unused arg only if it was unused in all modes,
    but this claim was false.

    Replace this old code with new code that

    - gathers the set of unused args in each procedure, recording
      which ones have mode "unused",

    - considers all the procedures of a predicate together, and then

    - generates either a single warning for the predicate as a whole,
      or separate warnings for each procedure that has unused arguments.

    We now generate a single warning for the predicate only if all the
    procedures agree both on which arguments are unused, and on
    which of those are *marked* by the mode as unused. Of course,
    most of the time this will be the case simply because most predicates
    have just one procedure.

    Stop module qualifying predicate names in the warnings we generate,
    since we do not generate warnings for imported predicates.

    Color the unqualified name as the subject of the diagnostic.

    When reporting unused args, list the arguments with "unused" modes
    separately from the other arguments.

    Simplify the interface with our caller in unused_args.m.

compiler/unused_args.m:
    Conform to the simplified interface with unused_args_warn_pragma.m.

compiler/hlds_error_util.m:
    Add a new version of an existing utility function.

tests/warnings/unused_args_some_modes.{m,err_exp}:
    Add a test case for the new capability.

tests/warnings/Mmakefile:
    Enable the new test case.

    Stop mixing "VAR = VALUE" and "Var += VALUE" definitions
    of make variables. Give some make variables better names.

    Move some dependency definitions out of a block of rules.

tests/warnings/Mercury.options:
    Enable --warn-unused-args for the new test case.

    Delete some accidentally-duplicated entries.

tests/warnings/unused_args_test.err_exp:
    Update the expected output.
2026-02-27 21:27:09 +11:00
Zoltan Somogyi
1bd50fb8a8 Add --boehm-write-size-map as a runtime option.
When specified (usually in the MERCURY_OPTIONS environment variable,
it tells the runtime to print how many words it allocates for each
request size.
2026-02-27 20:32:38 +11:00
Julien Fischer
f05dd00918 Fix an incorrect error message in an exception.
library/version_array2d.m:
    The row or column out of bounds messages are off by one; fix that.

tests/hard_coded/version_array2d_test.exp:
    Conform to the above change.
2026-02-27 20:16:56 +11:00
Julien Fischer
f3ff95db82 Add a missing determinism declaration.
extras/moose/moose.m:
    As above.
2026-02-27 17:20:53 +11:00
Julien Fischer
814f644c73 Fix documentation in complex number library.
extras/complex_numbers/complex_numbers.complex.m:
    Fix incorrect predicate name in documentation of complex_to_polar/3.
2026-02-27 17:02:02 +11:00
Julien Fischer
126677a832 Fix errors in the GLUT binding.
extras/graphics/mercury_glut/glut.callback.m:
    Rename overlay_display_func/2 -> disable_overlay_display_func/2
    for consistency with every other pair of callback predicates in
    this module.

    Add a space before a determinism declaration.

    Delete doubled-up tabled_for_io attributes from foreign_procs.

    Call the correct GLUT function to disable keyboard up callbacks.

extras/graphics/mercury_glut/glut.color_map.m:
    Fix incorrect argument ordering in a documentation comment.

extras/graphics/mercury_glut/glut.font.m:
    Fix formatting.

extras/graphics/mercury_glut/glut.m:
    Fix the definition of the glut_alpha/0 function, which was returning
    the wrong value.

extras/graphics/mercury_glut/glut.overlay.m:
    Fix a documentation comment.

    Add some tabled_for_io attributes.

extras/graphics/mercury_glut/glut.window.m:
    Fix doubled-up-word.

    s/__IO/_IO etc.
2026-02-27 16:49:38 +11:00
Julien Fischer
18f1cb69ee Fix some errors in the OpenGL binding.
extras/graphics/mercury_opengl/mogl.m:
    Fix incorrect casts in some of the calls to glRasterPosNd.

    Fix wording of an exception message.

    Fix incorrect constants in some foreign_enum pragmas.

    Fix a typo in a comment.
2026-02-27 16:22:13 +11:00
Julien Fischer
f5ca6b67a8 Fix some typos in the ODBC interface.
extras/odbc/odbc.m:
    As above.
2026-02-27 16:00:43 +11:00