Files
mercury/compiler/parse_tree.m
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

109 lines
3.6 KiB
Mathematica

%-----------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%-----------------------------------------------------------------------------%
% Copyright (C) 2002-2011 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
%
% This package contains the parse tree data structure,
% and modules for parsing and for manipulating parse trees.
%
% It corresponds to the parts of "Phase 1: Parsing"
% in notes/compiler_design.html up to (but not including) make_hlds.m.
%
:- module parse_tree.
:- interface.
:- import_module libs.
:- import_module mdbcomp.
% The parse tree data type itself.
% The parse tree is split in two. The parts defined in prog_item are needed
% only by the frontend of the compiler, the parts in prog_data are needed
% throughout.
:- include_module prog_item.
:- include_module prog_data.
:- include_module file_kind.
% The parser.
:- include_module prog_io.
:- include_module prog_io_dcg.
:- include_module prog_io_error.
:- include_module prog_io_find.
:- include_module prog_io_goal.
:- include_module prog_io_item.
:- include_module prog_io_mode_defn.
:- include_module prog_io_mutable.
:- include_module prog_io_pragma.
:- include_module prog_io_sym_name.
:- include_module prog_io_type_defn.
:- include_module prog_io_typeclass.
:- include_module prog_io_util.
% Parser/pretty-printer/utility routines for the ctgc related types.
:- include_module prog_ctgc.
% Pretty-printers.
:- include_module mercury_to_mercury.
:- include_module parse_tree_out.
:- include_module parse_tree_out_clause.
:- include_module parse_tree_out_inst.
:- include_module parse_tree_out_pragma.
:- include_module parse_tree_out_pred_decl.
:- include_module parse_tree_out_term.
:- include_module parse_tree_out_info.
:- include_module prog_out.
% Utility data structures.
:- include_module set_of_var.
% Utility routines.
:- include_module builtin_lib_types.
:- include_module error_util.
:- include_module item_util.
:- include_module maybe_error.
:- include_module prog_detism.
:- include_module prog_event.
:- include_module prog_foreign.
:- include_module prog_mode.
:- include_module prog_mutable.
:- include_module prog_rename.
:- include_module prog_type.
:- include_module prog_type_subst.
:- include_module prog_util.
% Transformations that act on the parse tree,
% and stuff relating to the module system.
:- include_module check_raw_comp_unit.
:- include_module comp_unit_interface.
:- include_module deps_map.
:- include_module equiv_type.
:- include_module file_names.
:- include_module generate_dep_d_files.
:- include_module get_dependencies.
:- include_module module_cmds.
:- include_module module_deps_graph.
:- include_module module_imports.
:- include_module module_qual.
:- include_module modules.
:- include_module read_modules.
:- include_module split_parse_tree_src.
:- include_module source_file_map.
:- include_module write_deps_file.
:- include_module write_module_interface_files.
% Java and C# related utilities.
:- include_module java_names.
% (Note that intermod and trans_opt also contain routines that
% act on the parse tree, but those modules are considered part
% of the HLDS transformations package.)
% :- include_module intermod.
% :- include_module trans_opt.
%-----------------------------------------------------------------------------%
:- end_module parse_tree.
%-----------------------------------------------------------------------------%