mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 03:13:40 +00:00
Github issue #118 reports a compiler abort that happens when table_gen.m attempts to perform that transformation that implements the tabling of I/O actions for declarative debugging, and a sanity check finds that the procedure's determinism is not model_det. We could change table_gen.m to not transform the affected predicate in such cases. This change could fix *this specific* compiler abort, but it is better to fix the root cause, which is that our semantic analysis passes have not detected and reported a violation of our semantic rules, and have allowed the affected predicate to flow through to the middle end to be processed. compiler/det_analysis.m: compiler/det_report.m: We used to check whether predicates with I/O state arguments have one of the permitted model_det determinisms as part of det_infer_proc. Github issue #118 arose because det_infer_proc processes only predicates defined in the current module. It was also strange that some properties of mode declarations were checked by det_infer_proc in det_analysis.m (which can be invoked on a procedure more than once during mode inference), while others were checked by check_determinism_of_procs in det_report.m (which is only ever invoked on a procedure once, at the end of determinism analysis). Move the checks on mode declarations all to det_report.m. Partly this is to fix the above code smell, but mainly so that we can add check_determinism_of_imported_procs, which performs the part of the job of check_determinism_of_procs that is appropriate for imported procedures. Make the error message for invalid mode declarations more specific by listing the given invalid determinism as well as the possible valid determinisms. To make the above possible without doing unnecessary checks on compiler-constructed procedures that are "born correct", separate out imported procedures from born-correct procedures. Previously, they were lumped together as "no inference needed" procedures. tests/invalid/ho_unique_error.err_exp: tests/invalid/mostly_uniq1.err_exp: tests/invalid/mostly_uniq2.err_exp: Expect the extra detail in error messages. tests/invalid/io_in_ite_cond.err_exp: tests/invalid/magicbox.err_exp: tests/invalid/try_detism.err_exp: Expect an error message about the invalid determinism of a procedure with I/O state args. Previously, we did not generate an error message for these issues.
35 lines
1.9 KiB
Plaintext
35 lines
1.9 KiB
Plaintext
try_detism.m:010: In `p'(out, di, uo):
|
|
try_detism.m:010: error: `cc_nondet' is not a valid determinism for a
|
|
try_detism.m:010: predicate that has I/O state arguments. The valid
|
|
try_detism.m:010: determinisms for such predicates are `det', `cc_multi' and
|
|
try_detism.m:010: `erroneous', since the I/O state can be neither duplicated
|
|
try_detism.m:010: nor destroyed.
|
|
try_detism.m:010: In `p'(out, di, uo):
|
|
try_detism.m:010: error: determinism declaration not satisfied.
|
|
try_detism.m:010: Declared `cc_multi', inferred `cc_nondet'.
|
|
try_detism.m:010: The reason for the difference is the following.
|
|
try_detism.m:017: In argument 1 of call to predicate `try_detism.q'/3:
|
|
try_detism.m:017: unification with `X' can fail.
|
|
try_detism.m:016: Error: call to predicate `exception.magic_exception_result'/1
|
|
try_detism.m:016: with determinism `cc_multi' occurs in a context which
|
|
try_detism.m:016: requires all solutions.
|
|
try_detism.m:017: Unification of X and V_17 can fail.
|
|
try_detism.m:016: In clause for `p(out, di, uo)':
|
|
try_detism.m:016: in call to predicate `exception.try_io'/4:
|
|
try_detism.m:016: mode error: arguments
|
|
try_detism.m:016: `TryLambda, TryResult, STATE_VARIABLE_IO_10, TryIOOutput'
|
|
try_detism.m:016: have the following insts:
|
|
try_detism.m:016: /* unique */ (pred(out, di, uo) is semidet),
|
|
try_detism.m:016: free,
|
|
try_detism.m:016: unique,
|
|
try_detism.m:016: free
|
|
try_detism.m:016: which does not match any of the modes for predicate
|
|
try_detism.m:016: `exception.try_io'/4.
|
|
try_detism.m:016: The first argument `TryLambda' has inst
|
|
try_detism.m:016: /* unique */ (pred(out, di, uo) is semidet),
|
|
try_detism.m:016: which does not match any of those modes.
|
|
try_detism.m:016: (For higher order insts like this, the mismatch is
|
|
try_detism.m:016: sometimes caused by the arity of the predicate or function
|
|
try_detism.m:016: being different in the inst than in the type.)
|
|
For more information, recompile with `-E'.
|