Commit Graph

3 Commits

Author SHA1 Message Date
Zoltan Somogyi
4f32c50822 Let clauses with unknown warnings be processed.
This implements Mantis feature request #497.

compiler/parse_goal.m:
compiler/parse_dcg_goal.m:
    When we find that a disable_warnings scope contains an unrecognized
    warning name, generate a warning for it, and return this warning
    *alongside*, not *instead of*, the disable_warnings scope goal.
    This requires passing around not a maybe1(goal), as we have been doing
    till now, but a maybe2(goal, list(warning_spec)), so this change
    affects both (1) most of these two modules, and (2) most of the
    modules below.

compiler/error_util.m:
    Provide warning_spec as a synonym for error_spec, to be used in
    situations like this where the "error_spec" is intended contain
    something with severity_warning.

compiler/maybe_error.m:
    Provide some new utility predicates now needed in parse_goal.m
    and elsewhere.

compiler/prog_item.m:
    Provide room in the representation of clauses for the warnings
    generated by parsing the clause body goal.

compiler/add_class.m:
compiler/add_clause.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/du_type_layout.m:
compiler/get_dependencies.m:
compiler/make_hlds_passes.m:
compiler/parse_item.m:
compiler/parse_tree_out_clause.m:
compiler/prog_item_stats.m:
compiler/superhomogeneous.m:
    Conform to the changes above.

tests/valid/unknown_warning.m:
    Add this test case that checks whether a source file with an unknown
    warning name in a disable_warnings scope can have code generated for it.

tests/warnings/unknown_warning.{m,exp}:
    Add the same source file to this directory as well, to check whether
    we get the right set of warnings.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/warnings/Mmakefile:
    Enable the two new test cases.
2020-04-05 19:09:31 +10:00
Zoltan Somogyi
d9e576a2b2 Specify the type for inst definitions.
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
mdbcomp/*.m:
ssdb/*.m:
    Specify the type constructor for every inst definition that lists
    the functors that values of that type may be bound to.

    In library/maybe.m, delete the inst maybe_errors/1, because
    (a) its name is misleading, since it is for the maybe_error/1 type (no s),
    and (b) there is already an inst with the non-misleading name maybe_error
    which had an identical definition.

    In compiler/dep_par_conj.m, delete two insts that were duplicates
    of insts defined in hlds_goal.m, and replace references to them
    accordingly.
2017-11-08 16:54:18 +11:00
Zoltan Somogyi
2f1ec6b91c Don't abort if a curried predicate has no declared determinism.
compiler/polymorphism.m:
    When it sees a curried predicate call, polymorphism converts it to an
    explicit lambda expression in order to add the unifications that
    construct the type_infos and/or typeclass_infos the call needs.
    For this, it needs to know the call's determinism. If the predicate had
    no declared determinism, we used to abort the compiler, which is
    too drastic a response to a simple programmer error.

    Change this so that in this situation, we simply report an error,
    and record that it is not safe to continue the compilation process.
    In reality, it is not safe to continue the compilation only of the
    predicate that the lambda expression occurs in, but in the vast, vast
    majority of cases, this should be more than good enough.

    I did try to code this change so that we continued the compilation
    of other predicates when this error occurs, but it turned out to be
    a bit too complicated for the very small potential benefit. Nevertheless,
    some of the changes below are the results of this attempt; I kept them
    because they are useful in their own right.

    Change the code for traversing the procedures of a predicate
    to be more direct.

    Put the access predicates in the poly_info type in the same order
    as the fields they operate on.

compiler/error_util.m:
    Allow recording that an error is discovered during the polymorphism pass.

compiler/mercury_compile_front_end.m:
    If polymorphism finds errors, print their messages, and then stop;
    don't continue to the later passes.

compiler/maybe_error.m:
    New module, containing the maybeN types (taken from prog_io_utio.m)
    and the safe_to_continue type (taken from modes.m). These are now
    needed by polymorphism.m as well.

compiler/parse_tree.m:
compiler/notes/compiler_design.html:
    Mention the new module.

compiler/options.m:
doc/user_guide.texi:
    Delete the (undocumented, developer-only) --no-polymorphism option,
    since its use cannot lead to anything other than a compiler abort,
    and this won't change in the future.

compiler/hlds_pred.m:
    Rename the "marker" type to "pred_marker", to clarify its purpose.
    Rename the "attribute" type to "pred_attribute", for the same reason.

    Make the pred_markers and attributes types true sets, not lists
    masquerading as sets.

    Add a predicate to add more than one marker at a time to a set of markers.

    Delete an unused predicate.

    Rename the functors of the can_process type to clarify its purpose.
    (I tried to use it to record the presence of errors discovered by
    polymorphism.m, and this did not work; these renames should spare
    others a similar experience.)

    Make the code that construct pred_infos build its components from first
    field to last field, not in random order.

compiler/det_analysis.m:
    Specialize an exported predicate to its actual uses.

compiler/hlds_out_pred.m:
    Dump the cannot_process_yet flag for procedures that have them.

compiler/add_pragma.m:
compiler/add_pred.m:
compiler/complexity.m:
compiler/deforest.m:
compiler/equiv_type_hlds.m:
compiler/field_access.m:
compiler/goal_expr_to_goal.m:
compiler/higher_order.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/ml_accurate_gc.m:
compiler/modecheck_goal.m:
compiler/modecheck_unify.m:
compiler/modecheck_util.m:
compiler/modes.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_item.m:
compiler/prog_io_mode_defn.m:
compiler/prog_io_mutable.m:
compiler/prog_io_pragma.m:
compiler/prog_io_sym_name.m:
compiler/prog_io_type_defn.m:
compiler/prog_io_typeclass.m:
compiler/prog_io_util.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/simplify_goal_unify.m:
compiler/ssdebug.m:
compiler/stm_expand.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/try_expand.m:
compiler/unify_proc.m:
    Conform to the changes above.

tests/invalid/higher_order_no_detism.{m,err_exp}:
    A new test case to test that the compiler does not abort, but generates
    an error message when it sees a curried predicate call to a predicate with
    no declared determinism.

tests/invalid/Mmakefile:
    Enable the new test case.
2015-10-07 00:44:14 +11:00