tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the debugger tests,
specify the new line numbers in .inp files and expect them in .exp files.
Estimated hours taken: 2
Branches: main, release
For unifications of the form X = f, we usually emit warnings if we know
from previous unifications that X cannot be bound to f. There was already
one exception to this: if some of the procedure's arguments had initial insts
such as in(g), because in such cases the failure of the unification could be
caused by this initial mode, and the exact same unification could succeed
in another mode in which the initial inst of that variable is in(f).
This diff adds another exception: when the unification is in code that was
duplicated by switch detection. Consider this code:
% switch on X
(
X = e,
...
;
( X = f
; X = g
; X = h
),
...
( X = f ->
...
;
...
)
)
The idea is that cases of f, g and h are handled mostly the same way, but that
f needs a bit of special handling. This used to give a warning, because the
switch detection creates three copies of the if-then-else: one each inside
the switch arms for f, g and h. In the arm for f, the condition cannot fail,
and in the arms for g and h, the condition cannot succeed, yet giving warnings
about the condition not being able to fail or succeed would be misleading.
compiler/hlds_goal.m:
Add a goal feature to denote that the goal is duplicated by switch
detection.
compiler/saved_vars.m:
Conform to the new feature.
compiler/switch_detection.m:
Attach this feature to goals as they are being duplicated.
compiler/mode_info.m:
Add a field to the mode_info that says whether we are inside such
goals.
compiler/modes.m:
compiler/unique_modes.m:
Set this field appropriately.
compiler/modecheck_unify.m:
When finding a unification of the form X = f where the inst of X
says that it cannot be bound to X, only generate a warning if we are
not inside a duplicated goal.
compiler/simplify.m:
Add a field to the simplify_ that says whether we are inside
a duplicated goal, keep it up to date, and don't generate warnings
about too-simple if-then-elses if the field say they could be due to
the code duplication.
tests/hard_coded/switch_detect.m:
Extend this existing test case to test the new behavior.
tests/hard_coded/Mercury.options:
Force the compilation of switch_detect.m to fail if there are any
warnings.
Estimated hours taken: 1
Branches: main
NEWS:
Mention the recent expansion in the capabilities of switch detection.
doc/reference_manual.texi:
Document the recent expansion in the capabilities of switch detection.
tests/hard_codes/switch_detect.{m,exp}:
Toughen this existing test to make it test what the documentation
promises: the ability to handle unifications before the inner
disjunction, and code after the unifications in the inner disjunction.
Estimated hours taken: 2
Branches: main
compiler/switch_detect.m:
Allow the detection of switches in which some disjuncts start not
with a unification, but with disjunction of unifications. In such
cases, the rest of the disjunct is duplicated for all the switch arms
we can create.
compiler/hard_coded/switch_detect.{m,inp,exp}:
New test case to test the new functionality.
compiler/hard_coded/Mmakefile:
Enable the new test case.