Commit Graph

4586 Commits

Author SHA1 Message Date
Julien Fischer
de8f79cac3 Better document error behaviour in random.system_rng.
library/random.system_rng.m:
     Better document the error behaviour of some predicates in this module.

     Adjust the header comment to group the description of what happens
     on Cygwin with the rest of the Windows description.

     Adjust a comment.
2026-02-24 21:08:25 +11:00
Julien Fischer
499559fceb Do not use bitwise and on booleans in Java.
library/time.m:
     As above.
2026-02-22 03:03:32 +11:00
Julien Fischer
a089b6626f Fix a bug in the C# system RNG.
library/random.system_rng.m:
    Fix an inverted Boolean in the implentation of generate_uint8/4.
2026-02-21 00:07:01 +11:00
Julien Fischer
d3c943500a More library fixes.
library/*.m:
    As above.
2026-02-20 23:57:09 +11:00
Julien Fischer
63ab40f515 More library documentation fixes.
library/*.m:

libary/map.m:
   Fix a variable name that was obviously the reuslt of a
   copy-and-paste error.
2026-02-20 21:05:08 +11:00
Julien Fischer
7c2cf9e946 Rationalise foreign_proc attributes in stdlib.
library/*.m:
    Remove tabled_for_io attributes from C# and Java foreign_procs.
    I/O tabling is not supported by those backends.

    Remove will_not_modify_trail attributes from C# and Java foreign_procs,
    and from predicates that do I/O. They have no effect in the former and
    cannot affect anything with the latter.

    Fix a spot a where will_not_modify_trail was given, but
    will_not_call_mercury was meant.
2026-02-20 19:19:26 +11:00
Julien Fischer
8a534df57c Library documentation fixes.
library/term_subst.m:
    Document when term_list_to_var_list/2 fails.

    Minor formatting fix.

library/term_to_xml.m:
    Fix a documentation error.
2026-02-20 16:20:42 +11:00
Julien Fischer
e3cc72cb0b Fix bug in term_io.format_term_nl/5.
library/term_io.m:
     foramt_term_nl/5 should call format_term_nl_with_op_table/6, *not*
     format_term_with_op_table/6, otherwise the terminating ".\n" will
     not be written.

tests/hard_coded/Mmakefile:
tests/hard_coded/format_term_nl.{exp,m}:
     Add a regression test.
2026-02-20 16:03:18 +11:00
Julien Fischer
a77da7b5ff More standard library fixes.
library/set_tree234.m:
    Delete a duplicate type_spec pragma.

library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/stack.m:
library/store.m:
    Documentation and formatting fixes.
2026-02-20 14:42:38 +11:00
Julien Fischer
7f771cb245 Fix rbtree.count and rbtree.ucount.
These were inadvertently broken by updates to programming style in
commit 185443d79.

library/rbree.m:
    In the implementation of ucount, increment the count for the
    current node.

tests/hard_coded/Mmakefile:
tests/hard_coded/rbtree_count.{m,exp}:
    Add a regression test.
2026-02-20 13:40:40 +11:00
Zoltan Somogyi
58ddc0dc4d Fix typo. 2026-02-19 18:13:31 +11:00
Julien Fischer
778e75f696 Fix problems in the library.
library/array.m:
library/builtin.m:
library/construct.m:
    Fix copy-and-paste errors.

library/arrayd2d.m:
    Use the mode array2d_di instead of array_di in a spot.

    Delete an extra space from an exception message.

library/bimap.m:
    Fix formatting.

library/bit_buffer.m:
    Fix inverted argument types.

library/dir.m:
    Say that make_single_directory/4 returns an error rather
    than saying that it fails.

library/io.m:
    Fix errors in obsolete pragmas.

library/assoc_list.m:
library/bag.m:
library/cord.m:
library/deconstruct.m:
library/enum.m:
library/fat_sparse_bitset.m:
library/getopt*.m:
library/int*.m:
library/io*.m:
library/type_desc.m:
    Fix documentation errors.

tests/hard_coded/array2d_from_array.exp:
    Conform to the changed exception message in array2d.m.
2026-02-19 15:24:59 +11:00
Julien Fischer
06fe5931d3 Documentation and obsolete pragma fixes.
library/char.m:
    Fix description of character ranges recognised by hex_digit_to_int/2.

library/pretty_printer.m:
    Fix a copy-and-paste error.

library/string.m:
    Fix errors in predicate descriptions.

    Fix obsolete pragmas that specified the replacement predicate to
    be the target of the pragma.
2026-02-18 23:31:27 +11:00
Julien Fischer
68a3e2a297 Documentation fixes for the map module.
library/set.m:
    As above; in particular fix inverted section headings.
2026-02-18 21:18:30 +11:00
Julien Fischer
97ad29f37b Fix documentation of set.map2_fold/6.
library/set.m:
    As above.
2026-02-18 21:05:36 +11:00
Julien Fischer
f4b40d9ca4 Adjust documentation for random.normal_floats/7.
library/random.m:
    Use variable naming that is consistent with the ground generator version of
    normal floats and doesn't clash with the state.
2026-02-18 15:31:30 +11:00
Julien Fischer
d4bb2dcdf4 Minor documentation fix.
library/math.m:
    Fix description of solve_quadratic/3.
2026-02-18 15:08:23 +11:00
Julien Fischer
0c72ee7370 Fixes for io module documentation.
library/io.m:
    Fix some copy-and-paste errors.

    Fix grammar and punctuation.
2026-02-18 15:00:47 +11:00
Julien Fischer
61e7f23d19 Fixes for list module documentation.
library/list.m:
    As above, mainly copy-and-paste errors.
2026-02-18 14:34:41 +11:00
Julien Fischer
1adccd0b65 Fix typos in integer module.
library/integer.m:
    As above.
2026-02-16 15:50:34 +11:00
Julien Fischer
39db3051b8 Fix errors in thread.future.
library/thread.future.m:
    Fix documnetation errors.
2026-02-16 14:30:14 +11:00
Julien Fischer
bbd760e67c Fix errors in thread.barrier.
library/thread.barrier.m:
    Fix errors documentation.

    Fix an incorrect error message.
2026-02-16 14:18:33 +11:00
Julien Fischer
66a346e41d Fix errors in version_store documentation.
library/version_store.m:
    As above.
2026-02-16 14:06:32 +11:00
Julien Fischer
8f61d08328 Fix errors in version_array2d documentation.
library/version_array2d.m:
    As above.
2026-02-16 13:56:50 +11:00
Julien Fischer
86969081cb Adjust version_array documentation.
library/version_array.m:
     As above.
2026-02-16 13:48:24 +11:00
Zoltan Somogyi
e513a340fb A minor style improvement. 2026-02-16 12:47:25 +11:00
Zoltan Somogyi
36e8833145 Add a new option, --warn-unused-types.
When set, this option tells the compiler to generate warnings
about locally-defined types that are neither used in the module
nor exported to any other module.

compiler/options.m:
    Add the new option.

compiler/unused_types.m:
    New module to implement the new option.

compiler/mercury_compile_front_end.m:
    Invoke the new module, unless the presence of previous errors
    would make its warnings just a distraction.

compiler/check_hlds.m:
    Include the new module.

compiler/notes/compiler_design.html:
    Document the new module.

compiler/typecheck_error_wrong_type.m:
    Simplify some code.

browser/declarative_tree.m:
compiler/accumulator.m:
compiler/du_type_layout.m:
compiler/intermod.m:
compiler/mode_errors.m:
compiler/parse_inst_mode_defn.m:
compiler/polyhedron.m:
compiler/split_parse_tree_src.m:
compiler/tag_switch_util.m:
compiler/typecheck_error_unify.m:
compiler/unneeded_code.m:
deep_profiler/mdprof_test.m:
library/getopt.m:
library/getopt_io.m:
    Delete unused types reported by the new option.

library/rtti_implementation.m:
    Comment out unused type reported by the new option. This type was exported
    to both Java and C#, but this diff comments it out because neither language
    the Java or the C# runtime system seems to use the exported versions
    either. (Bootcheck in both java and csharp grades worked, with the
    same number of test case failures as before.) We do not delete it,
    because it may be useful in the future.

tests/warnings/help_text.err_exp:
    Expect the documentation of the new option.

tests/invalid_nodepend/Mmakefile:
    Specify --warn-unused-types for two test cases to test that the compiler
    does NOT generate warnings about unused types in the presence of previous
    errors.

tests/warnings/abstract_type_decl.err_exp:
tests/warnings/bug412.err_exp:
tests/warnings/warn_dead_procs.err_exp:
    Expect the new warnings for unused types.

tests/warnings/Mmakefile:
    Specify --warn-unused-types for the three test cases listed above.
2026-02-15 11:26:34 +11:00
Julien Fischer
5315e73e12 Address review comments.
library/calendar.m:
    As above.
2026-02-13 20:34:52 +11:00
Julien Fischer
592e67dad5 Document the duration/0 type more thoroughly.
This addresses an XXX added by Zoltan in commit eb623b17a,
which misunderstands what the intended semantics of the duration/0
type are.

library/calender.m:
    As above.
2026-02-13 19:31:04 +11:00
Julien Fischer
cb391eb967 Fix documentation and formatting.
library/mercury_term_lexer.m:
library/sparse_bitset.m:
library/uint64.m:
     As above.
2026-02-12 21:59:25 +11:00
Julien Fischer
a88b2a648e Fix method reference in stream documentation.
library/stream.m:
    The arity of bulk_get is 9, not 4.
2026-02-12 14:04:05 +11:00
Julien Fischer
b9f36b87f7 Update some documentation.
library/string.m:
    Fix the description of the range of integers that to_int/2
    and det_to_int/1 can produce. It can include min_int.
2026-02-12 13:55:35 +11:00
Julien Fischer
781265b060 Add a missing word.
library/string.m:
    As above.
2026-02-12 13:06:57 +11:00
Julien Fischer
6c1a717a1c Fix more calendar documentation.
library/calendar.m;
    Fix incorrect argument ordering in a comment.

    Avoid an ambiguity.
2026-02-10 17:13:19 +11:00
Julien Fischer
76c32768f1 Fix copy-and-paste error.
library/calendar.m;
    As above.
2026-02-10 16:12:55 +11:00
Julien Fischer
32c7199b2f Add a missing dereference.
library/random.system_rng.m:
    As above (this code is only used where no system RNG is available,
    which is why this hasn't been noticed).
2026-02-01 02:57:42 +11:00
Zoltan Somogyi
b61209812b Fix sentence structure. 2026-01-30 15:28:59 +11:00
Zoltan Somogyi
2448461ae1 Warn about singletons for *all* foreign procs.
compiler/add_foreign_proc.m:
    The existing code for adding foreign_procs

    - tests whether the foreign_proc is for an imported predicate,
      and if so, stops with an error message,

    - then tests whether the foreign_proc is for the current backend,
      and if it is not, ignores the foreign_proc,

    - and then both adds the foreign proc to the HLDS, and checks it
      for singletons.

    Reverse the order of the last two tests, so that we now test
    foreign_procs for singletons *even if* they are not for the current
    backend. (Though of course we do not add such foreign_procs to the HLDS.)

library/io.environment.m:
library/private_builtin.m:
library/rtti_implementation.m:
    Fix the warnings for now result for non-C foreign_procs even during
    bootchecks in C grades.

tests/warnings/foreign_singleton.err_exp:
    Expect warnings for Java and C# foreign_procs as well as C foreign_procs.

tests/warnings/singleton_test.{m,err_exp}:
tests/warnings/warn_return.{m,err_exp}:
tests/warnings/warn_succ_ind.{m,err_exp}:
    Make these test cases more readable. Delete any obsolete parts,
    as well as the causes of warnings that these test cases are
    not intended to test for. (The latter makes the tests' *outputs*
    more readable.)

    Expect warnings for Java and C# foreign_procs as well as C foreign_procs,
    and expect them with the new line numbers.

tests/warnings/foreign_singleton.err_exp2:
tests/warnings/foreign_singleton.err_exp3:
tests/warnings/singleton_test.err_exp2:
tests/warnings/singleton_test.err_exp3:
tests/warnings/warn_return.err_exp2:
tests/warnings/warn_return.err_exp3:
tests/warnings/warn_succ_ind.err_exp2:
tests/warnings/warn_succ_ind.err_exp3:
    Delete these Java- and C#-specific expected outputs, since the warnings
    they test for are now in the corresponding .err_exp files.
2026-01-29 22:09:58 +11:00
Zoltan Somogyi
41b96317c1 Pass the CSD arg to profiling builtins explicitly.
runtime/mercury_deep_rec_depth_body.h:
    Instead assuming that the code #including this file has a variable
    named CSD in scope, get the caller to pass that variable via a macro.

library/profiling_builtin.m:
    Pass that variable using that macro. Since the macro definition is
    not a comment, it won't get a singleton warning. Mark the CSD argument
    of the relevant predicates as not-a-singleton.
2026-01-29 00:11:37 +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
Julien Fischer
de0a5b005d Add a predicate version of set_ctree234.power_intersect/2.
library/set_ctree234.m:
    As above (all of the other set*.m modules provide this).

NEWS.md:
    Announce the addition
2026-01-24 02:19:11 +11:00
Zoltan Somogyi
561c62ba01 Improve the documentation of some library modules.
library/assoc_list.m:
library/deconstruct.m:
library/integer.m:
library/io.m:
library/store.m:
library/string.m:
library/thread.channel.m:
library/type_desc.m:
library/varset.m:
    As above.
2026-01-24 02:05:07 +11:00
Julien Fischer
0b92543c5e Fix more library documentation errors.
library/*.m:
   As above.
2026-01-23 19:53:58 +11:00
Julien Fischer
b85f11b41d Fix library documentation errors.
library/*.m:
    As above.

library/getopt.m:
    Regenerate this file.
2026-01-22 21:22:38 +11:00
Julien Fischer
1e68186081 Minor fixes for library documentation.
library/library.m:
    As above.
2026-01-21 20:13:04 +11:00
Zoltan Somogyi
8583f96d25 Add unsigned versions of version_array2d operations.
library/version_array2d.m:
    For every predicate or function that takes an integer argument,
    if that integer is required to be non-negative, add an unsigned version.

    Add bounds checks to lookup (read) and set (write) operations.

    Improve the documentation of the exported operations.

    Add a new implementation of the function that returns the rows
    of the array as a list of lists.

    Improve variable names in operations that have new unsigned versions.

NEWS.md:
    Announce the new operations.

tests/hard_coded/version_array2d_test.{m,exp}:
    New test case to test the operation of version_array2d.m.
    It is based on the applicable parts of version_array_test.m,
    but with somewhat improved organization.

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

tests/hard_coded/version_array_test.m:
    Minor style fixes.
2026-01-20 12:11:19 +11:00
Zoltan Somogyi
b6b4e85067 Add unsigned versions of version_array operations.
library/version_array.m:
    For every predicate or function that takes an integer argument,
    if that integer is required to be non-negative, add an unsigned version.

    Improve the documentation of the exported operations.

    Improve variable names in operations that have new unsigned versions.

NEWS.md:
    Announce the new operations.

tests/hard_coded/version_array_test.m:
    Modify this test case to test the new operations.
2026-01-19 19:27:50 +11:00
Zoltan Somogyi
950edaa6c9 Describe each cluster of related library modules. 2026-01-08 22:58:17 +11:00
Zoltan Somogyi
9ef5357c60 Improve readability. 2026-01-08 12:29:27 +11:00
Zoltan Somogyi
a94ac41af2 Fix a comment. 2026-01-08 09:16:16 +11:00