The date/0 type is misnamed. Values of the type have both a date and a time
component. The common name for combined date and time values is a "date_time",
for which we have had a type synonym since 2014. This change makes date_time
the proper name for type and make date into the type synonym.
Deprecate the date/0 name and note that we will change its meaning in a future
release. (It will eventually be used for data values that do not have a time
component.)
Rename predicates and functions accordingly and mark the existing versions as
obsolete.
library/calendar.m:
Make the above renamings.
library/hard_coded/stream.string_writer.m:
Replace a call to a now obsolete function.
NEWS.md:
Add entry describing the above.
tests/hard_coded/calendar_init_date.{m,exp}:
tests/hard_coded/calendar_test.m:
tests/hard_coded/fold_days.m:
tests/hard_coded/stream_string_writer_types.m:
Conform to the above changes.
Add a predicate to the calendar module for testing if a year is a leap year.
Use a more efficient method for determining this than the existing code
in the implementation of this module used (and replace that code with
a call to the new predicate).
Add the function days_to_month/2, which is a strongly typed wrapper
for the implementation function max_day_in_month_for/2.
Add a new test case covering basic operations in the calendar module,
together with the newly added operations.
library/calendar.m:
As above.
NEWS.md:
Announce the new additions.
tests/hard_coded/Mmakefile:
tests/hard_coded/calendar_basics.{m,exp}:
Add the new test case.
tests/debugger/Mmakefile:
Delete the bespoke make rules for test cases that do not require
their own special handling.
tests/debugger/all_solutions.exp:
tests/debugger/all_solutions.exp2:
tests/debugger/all_solutions.exp4:
tests/debugger/browse_packed.exp:
tests/debugger/browse_pretty.exp:
tests/debugger/class_decl.exp:
tests/debugger/cmd_quote.exp:
tests/debugger/debugger_regs.exp:
tests/debugger/field_names.exp:
tests/debugger/implied_instance.exp:
tests/debugger/label_layout.exp:
tests/debugger/list_cmd.exp:
tests/debugger/lval_desc_array.exp:
tests/debugger/multi_parameter.exp:
tests/debugger/multi_parameter.exp2:
tests/debugger/mutrec.exp:
tests/debugger/no_inline_builtins.exp:
tests/debugger/queens_rep.exp:
tests/debugger/shallow.exp:
tests/debugger/shallow.exp2:
Expect standardized event numbers and call sequence numbers,
since that is what the implicit rule specifies.
tests/debugger/all_solutions.m:
Fill in missing info about which .expN file is for what situations.
library/float.m:
Remove out-of-date references to ANSI C, POSIX, C9X (C99), and
platform-specific behaviour on Linux, Digital Unix and Solaris.
All current Mercury backends use (and are _required_ to use) IEEE floating
point; delete conditional language about this.
Do not specify halting with runtime error as a resolution for NaNs or
signed zeros; instead just say we should throw an exception.
Generalise the discussion of excess precision.
(XXX ideally we could get rid of this by telling C compilers not to
use extended-precision FP registers on those system that provide
them; most of them do that by default anyway, but I'm not sure if
all of them do.)
Delete parts of an action that are needed only on machines running OSF-1.
Delete parts of an action that have been obsolete since we switched
to '.' as the module qualifier character decades ago.
mul_by_digit(0, Y) produced i(Len, [0, 0, ...]) instead of the
canonical integer.zero = i(0, []). Since is_zero/1 only matched
the canonical form, denormalized zeros were silently treated as
nonzero, causing incorrect results in rational.m (e.g., gcd_2
non-termination, division-by-zero crashes in big_quot_rem).
Three fixes applied:
- Guard mul_by_digit and printbase_mul_by_digit to return
integer.zero when the digit is 0 (root cause fix).
- Make is_zero/1 recognize denormalized all-zero digit lists
as defense in depth.
- Replace structural `= integer.zero` checks in rational.m
with integer.is_zero/1 calls for robustness.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
library/dir.m:
Add some missing semicolons to some statements in foreign_proc body.
(The code in question compiled because we wrap foreign proc bodies
int { ;}.)
doc/mercury_reference_manual.texi:
Fix inverted characters.
Fix incorrect variable names in examples and the description
of the DCG transformation.
Fix an incorrect Java foreign_proc example.
Fix the example of higher-order impure code; it would not
compile as written.
library/calendar.m:
Reword the module header to mention microsecond resolution.
Reword the description of the leap year rule in the header.
Document the failure conditions of init_date/8, date_from_string/2
and duration_from_string/2. Mention that date_from_string/2 accepts
negative years, years with more than four digits, and fractional
seconds with between one and six digits.
Document that date_to_string/1 can produce negative years in its
output.
Document the microsecond and timezone limitations of
current_local_time/3 and current_utc_time/3.
Expand the documentation of julian_day_number/1 to explain what
a Julian day number is.
Expand the documentation of the duration type to cover sign constraints,
clamping behaviour, the treatment of leap seconds, internal normalisation
rules, and the relationship between init_duration/7 arguments and component
access function return values.
Document the ranges returned by the duration component access functions for
both positive and negative durations.
Document the sign constraint and exception behaviour of init_duration/7.
Expand the documentation of duration_from_string/2 to cover
negative durations, the six-digit fractional seconds limit,
and the normalisation round-trip example.
Rewrite the documentation of duration/2 to describe the
non-invertibility of duration/2 and add_duration/3 more concisely.
Simplify the documentation of foldl_days/5.
Various other minor documentation and formatting changes.
The crash that this diff fixes occurred when giving a command such as
"print Var^1" to mdb, where the first argument of Var is a direct arg.
runtime/mercury_ml_expand_body.h:
When deconstructing a term with a direct arg, return NULL
as the value of expand_info->chosen_arg_word_sized_ptr.
The crash occurred when we returned a non-null pointer,
which violated the expectations of trace/mercury_trace_vars.c
and its callers. (Not surprising, since those that function and
its callers were written long before the direct_arg optimization
was added to the system.)
runtime/mercury_deconstruct.h:
Document the rationale behind the above changes. (The contents of
mercury_ml_expand_body.h are #included in mercury_deconstruct.c.)
trace/mercury_trace_vars.c:
Add the debugging code I used to track down this issue, in disabled form.
Fix missing copyright year.
trace/mercury_trace_browse.c:
Delete obsolete comment.
Fix missing copyright years.
tests/debugger/direct_arg_test.{m,inp,exp}:
A test case for this bug.
tests/debugger/Mmakefile:
Enable the new test case.
compiler/hlds_out_type_table.m:
When dumping out the data constructors in the type table,
if a constructor has names for some of its fields,
put the name and the type of each field on different lines.
In the original test case for this bug, of which direct_arg_test.m
is an extreme simplification, pretty much every line overflows
without this.
Also, factor out some duplicated code, and replace bools with values
of a bespoke type.
Due to a copy-and-paste error introduced in commit 05fd615471,
set_line_number/2 was incorrectly setting the line number of the
current output stream, not the current input stream.
library/io.m:
Fix the above bug.
tests/hard_coded/Mmakefile:
tests/hard_coded/bad_set_line_number.{m,exp}:
Add a regression test.
Add a test for date creation, which is missing from existing calendar test.
In particular, test for the presence of the init_date argument lower bound
checks that were added in commit 5512b1be7.
tests/hard_coded/Mmakefile:
tests/hard_coded/calendar_init_date.{m,exp}:
Add the new test case.
runtime/Mmakefile:
Some time ago, autoconf seems to have changed the text it puts
into the files it generates, including mercury_conf.h.
This broke the old code we had in this file that looked for
the old text. Fix this by updating the pattern we look for.
Document updates to autoconf as possible reasons for any future
reoccurrence of this bug.
Document the reason why we "standardize" the autoconfigured contents
of mercury_conf.h.
Fix programming style.
configure.ac:
The changes in this file are only stylistic; they made it easier
to track down the above bug.
Put a comment about "order matters" *before* the lists whose order
matters. Define the first of two lists being concatenated first
(since order matters not just for code correctness, but also for
reading comprehension :-().
Fix misleading indentation.
Add an XXX about some (seemingly) unneeded code.
configure.ac:
Require the installed compiler to support that option.
STANDARD_MCFLAGS:
Specify that option.
compiler/canonicalize_interface.m:
compiler/comp_unit_interface.m:
compiler/inst_user.m:
compiler/parse_module.m:
compiler/switch_util.m:
compiler/type_ctor_info.m:
deep_profiler/mdprof_dump.m:
library/digraph.m:
slice/mcov.m:
Delete unused equivalence types that were picked up by the option.
... in some contexts.
compiler/unused_types.m:
Implement the easy part of the above, the part that happens
*after* we collect the info about which equivalence types are used.
Document why we can report unused equivalence types only in some contexts.
compiler/prog_data_used_modules.m:
Define an extension of the used_modules type that also records
which equivalence types were expanded in the module.
Define the operations we need on this extended type.
compiler/equiv_type.m:
Invoke one of those operations to record the expansions of equivalence
types, if requested to do so.
Inline the predicate that used to do this at its only call site.
compiler/hlds_module.m:
Replace the used_module field in the module_info with a value of
the extended type that includes not just the old used_modules info,
but also the set of expanded equivalence types.
Delete a utility predicate on the old field. The last call to this
predicate was deleted on 2022 march 30.
compiler/equiv_type_parse_tree.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile_make_hlds.m:
compiler/unused_imports.m:
Conform to the changes above.
tests/warnings/warn_dead_procs.{m,err_exp}:
This test case already tests for warnings about unused du types.
Extend it to also test for unused eqv types.
library/int32.m:
Add these library operations.
NEWS.md:
Announce the new operations.
compiler/lookup_switch_util.m:
Use the checked operations added by this diff and other recent diffs
to replace unchecked casts.