mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-21 20:33:55 +00:00
We used to have several predicates whose job was to simplify modes for
presentation to users. Their jobs were slightly different, but contained
a shared core: recognizing the exploded (from_inst >> to_inst)
forms of the standard builtin modes. Replace these
compiler/prog_mode.m:
Moves an existing predicate in parse_tree_out_inst.m for recognizing
the standard builtin modes to prog_mode.m, to make it generally available.
Refactor the existing insts_to_mode predicate to use this predicate.
Make insts_to_mode recognize mdi(I) modes as well.
Add utility predicates for stripping all type_inst wrappers from
insts and modes. Base these on the similar utility predicates
for stripping builtin qualifiers from insts and modes. Export
all meaningful variants of both sets of utilities.
Use variables named InstNameX for inst names; the old InstX names
were misleading, since the inst_name type is different from mer_inst.
compiler/parse_tree_out_inst.m:
Delete the code moved to prog_mode.m.
Use the updated functionality in prog_mode to simplify modes.
This means that we can now simplify all in(...) modes, not just
when the ... is a higher order inst.
Strip module qualifiers from modes when printing output for humans
(and *only* for humans), since in 99.9+% of cases they are clutter.
compiler/error_msg_inst.m:
Replace the old code for recognizing standard modes with calls
to the predicates in prog_mode.m. They can do a better job than
the old code did. The recognize arity 1 standard modes, not just
arity 0, and they remove typed_inst wrappers everywhere in insts,
not just at the top level.
compiler/hlds_out_util.m:
Fix an old bug: don't *assume* that any modes being converted to string
are intended only for humans; get our callers to *tell us* whether
that is the case. When intermod.m uses hlds_out_goal.m to write out
the modes on the arguments of lambda goals, this is *not* the case,
since some transformations intended for humans, such as stripping
module qualifications, can actually break things.
Give a field in the hlds_out_info a more meaningful name.
compiler/hlds_out_goal.m:
compiler/hlds_out_module.m:
compiler/intermod.m:
compiler/mode_errors.m:
Conform to the changes in hlds_out_util.m.
tests/invalid/ho_any_inst.err_exp:
tests/invalid/ho_default_func_4.err_exp:
tests/invalid/mode_inf.err_exp:
Expect the updated forms of modes in error messages.
17 lines
786 B
Plaintext
17 lines
786 B
Plaintext
ho_default_func_4.m:036: In clause for `baz(in, out)':
|
|
ho_default_func_4.m:036: in call to function `univ.univ'/1:
|
|
ho_default_func_4.m:036: mode error: argument `V_7' and the return value
|
|
ho_default_func_4.m:036: `V_6' have the following insts:
|
|
ho_default_func_4.m:036: /* unique */ (func(
|
|
ho_default_func_4.m:036: in(named inst one,
|
|
ho_default_func_4.m:036: which expands to
|
|
ho_default_func_4.m:036: bound(
|
|
ho_default_func_4.m:036: 1
|
|
ho_default_func_4.m:036: )
|
|
ho_default_func_4.m:036: )
|
|
ho_default_func_4.m:036: ) = out is det),
|
|
ho_default_func_4.m:036: free
|
|
ho_default_func_4.m:036: which does not match any of the modes for function
|
|
ho_default_func_4.m:036: `univ.univ'/1.
|
|
For more information, recompile with `-E'.
|