mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 19:03:45 +00:00
b357a3dadcdf29c8d8ca184d65f7634a1a94de36
10 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fdd141bf77 |
Clean up the tests in the other test directories.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
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 tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
|
||
|
|
6de9f4d1e3 |
Modify the type and purity check passes to gather up all error messages,
Estimated hours taken: 8 Branches: main Modify the type and purity check passes to gather up all error messages, and print them all at once after sorting. compiler/typecheck.m: compiler/typeclasses.m: compiler/post_typecheck.m: compiler/purity.m: Gather up all error messages instead of printing them when generated. In some places the gathered list of error specifications allows us to eliminate error counts and error flags. Eliminate the last occurrences of io.write_* in these modules, replacing them with error_specs. Change the error messages generated by purity.m to eliminate the unnecessary module qualification of the name of the predicate or function in which the error occurs. compiler/typecheck_errors.m: Turn the predicates here that used to print error messages into functions that just return the error specification. compiler/mode_errors.m: Make a predicate used by post_typecheck.m return an error spec instead of writing it out. compiler/typecheck_info.m: Record the list of errors instead of simple a count of the errors printed. compiler/mercury_compile.m: Print the error message batches returned by type checking and purity checking. compiler/error_util.m: Modify the way we represent severity to allow passes such as typechecking to count the number of errors *without* printing anything. compiler/add_pred.m: compiler/det_report.m: compiler/make_hlds_warn.m: compiler/module_qual.m: Conform to the change in error_util.m. compiler/Mercury.options: Record the fact that some more compiler modules need the workaround for trace goals. tests/invalid/*err_exp: tests/warnings/*exp: Update the expected output files to conform to the changes above. This mosly involves expecting sorted messages without duplicates. |
||
|
|
5eee81204e |
A big step towards cleaning up the way we handle errors.
Estimated hours taken: 28 Branches: main A big step towards cleaning up the way we handle errors. The main changes are - the provision, in error_util.m, of a mechanism for completely specifying everything to do with a single error in one data structure, - the conversion of typecheck_errors.m from using io.write_string to using this new capability, - the conversion of mode_errors.m and det_report.m from using write_error_pieces to using this new capability, and - consistently using the quoting style `symname'/N instead of `symname/N' in error_util and hlds_error_util (previously, error_util used the former but hlds_error_util used the latter). This diff sets up later diffs which will collect all error specifications in a central place and print them all at once, in order. compiler/error_util.m: The new type error_spec, which completely specifies an error. An error_spec may have multiple components with different contexts and may have parts which are printed only under certain conditions, e.g. a given option being set. Each error_spec has a severity and also records which phase found the error. The new predicate write_error_spec takes care of updates of the exit status for errors and (if --halt-at-warn is set) for warnings. It also takes care of setting the flag that calls for the reminder about -E at the end. This diff also makes it simpler to use the ability to print arbitrary output. It adds the ability to include integers in messages directly, and the ability to create blank lines. It renames some function symbols to avoid ambiguities. Move a predicate that only used by typecheck_errors.m to that file. compiler/hlds_error_util.m: Switch to the `symname'/N quoting style for describing predicates and procedures. compiler/prog_util.m: Switch to the `symname'/N quoting style for describing sym_name_and_arity. compiler/hlds_module.m: Provide a predicate to increment the number of errors not by one, but by the number of errors printed by write_error_spec. Fix some documentation rot. compiler/typecheck_errors.m: Use write_error_spec instead of io.write_strings to print error messages. In several cases, improve the formatting of the messages printed. Mark a number of places where we don't (yet) update the number of errors in the module_info correctly. Rename the checkpoint predicate to avoid potential ambiguity with similar predicates in e.g. mode_info. compiler/typecheck_info.m: Group the code for writing stuff out together in one bunch. For each such predicate, create another that returns a list of format components instead of doing I/O directly. compiler/typecheck.m: Move the code for writing inference messages here from typecheck_errors.m, since these messages aren't errors. compiler/mode_errors.m: compiler/det_report.m: Use write_error_spec instead of write_error_pieces. In the case of mode_errors.m, this means we now get correct the set of circumstances in which we set the flag that calls for the reminder about -E. compiler/add_pragma.m: compiler/add_type.m: Convert some code that used to use write_error_pieces to print error messages to use write_error_spec instead. compiler/assertion.m: compiler/hlds_pred.m: compiler/post_typecheck.m: Assertion.m used to contain some code to check for assertions in the interface that mention predicates that are not exported. Move most of this code to post_typecheck.m (which is where this code used to be called from). One small part, which is a test for a particular property of import_statuses, is moved to hlds_pred.m to be with all the other similar tests of import_statuses. compiler/prog_util.m: Change unqualify_name from a predicate to a function. compiler/pred_table.m: compiler/hlds_out.m: Avoid some ambiguities by adding a suffix to the names of some predicates. compiler/*.m: Conform to the changes above. library/list.m: Add a function that was previously present (with different names) in two compiler modules. tests/hard_coded/allow_stubs.exp: Update the format of the expected exception. tests/invalid/errors2.err_exp2: Remove this file. As far as I can tell, it was never the correct expected output on the main branch. (It originated on the alias branch way back in the mists of time.) tests/invalid/*.err_exp: tests/invalid/purity/*.err_exp: tests/warnings/*.exp: Update the format of the expected error messages. tests/recompilation/*.err_exp.2: Update the format of the expected messages about what was modified. |
||
|
|
e069d16ab1 |
Do not display the For more information try recompiling with -E'' prompt
Estimated hours taken: 1.5 Branches: main Do not display the `For more information try recompiling with `-E'' prompt unless we really mean it, i.e. there is actually more information available. XXX This change is incomplete for the mode_errors module because that module requires more substantial changes to make this work - I'll do that as a separate diff. compiler/globals.m Add a new global (and access predicates) that keeps track of whether we have any verbose error information that could be displayed if we recompiled with `-E'. compiler/mercury_compile.m Check the new global flag before prompting the user to recompile with `-E'. compiler/mode_errors.m Add an XXX comment about needing to respect the extra error info flag properly. compiler/accumulator.m compiler/add_clause.m compiler/add_pred.m compiler/add_type.m compiler/assertion.m compiler/check_typeclass.m compiler/det_report.m compiler/magic_util.m compiler/make_hlds_error.m compiler/modes.m compiler/module_qual.m compiler/modules.m compiler/post_typecheck.m compiler/purity.m compiler/stratify.m compiler/typecheck_errors.m Set the new global flag when we come across an error for which we have a verbose error message. tests/recompilation/*: tests/invalid/*: Update expected error files. |
||
|
|
a0e5667af5 |
Do not allow non-abstract instance declarations to occur in module
For review by anyone. Estimated hours taken: 10 Branches: main, release Do not allow non-abstract instance declarations to occur in module interfaces. Emit an error message if this occurs. Fix the formatting of some error messages regarding typeclasses and instances. compiler/check_typeclass.m: Use error_util to generate the error messages from this module. This fixes a problem where the printing of sym_names and arities differed in the same error message. compiler/error_util.m: Add a format component for the pred_or_func type. Add the equivalence type format_components. compiler/make_hlds.m: Make the format of some error messages concerning typeclasses more consistent. compiler/modules.m: Check for non-abstract instance declarations in module interfaces and emit an error message if they do. tests/invalid/Mmakefile: tests/invalid/instance_bug.m: tests/invalid/instance_bug.err_exp: Test case for the above. tests/hard_coded/typeclasses/*: tests/invalid/*: tests/recompilation/*: tests/valid/*: Update test cases as necessary. |
||
|
|
9187c0d911 |
Bring these modules up to date with our current style guidelines.
Estimated hours taken: 8 Branches: main compiler/hlds_out.m: compiler/llds_out.m: Bring these modules up to date with our current style guidelines. Use state variables in the few places where we weren't doing so already. compiler/purity.m: Bring this module up to date with our current style guidelines. Use the predicates of error_util and hlds_error_util to print error messages. Be more consistent in using quotations. Fix indentation. compiler/error_util.m: Add a long needed facility: the ability to glue some punctuation at the end of a previous word. Add a mechanism for turning a list of components into a string, instead of printing them out. Make the interface of this module more consistent by making list_to_pieces a function just like component_lists_to_pieces. compiler/hlds_error_util.m: Change the way we describe predicates and procedures. Instead of returning their descriptions as single fixed strings that error_util can't break up across lines, return them as separate components that can be split across lines. This makes error output look nicer. Fix a mismatch between what were supposed to be corresponding pieces of code in hlds_error_util and hlds_out. Turn the appropriate predicates into functions. compiler/*.m: Conform to the changed interfaces of some of the above modules. tests/invalid/*.err_exp: tests/invalid/purity/*.err_exp: tests/recompilation/*.err_exp: tests/warnings/*.exp: Update the expected outputs for the better looking error messages we now generate. |
||
|
|
a8ffd3680c |
Change the compiler and tools so that .' and not :' is now used as the
Estimated hours taken: 14 Branches: main Change the compiler and tools so that `.' and not `:' is now used as the module separator in all output. Infix `.' now has associativity yfx and priority 10. NEWS: Report the change. configure.in: Amend the test for an up-to-date Mercury compiler to check whether it recognises `.' as a module qualifier. compiler/code_gen.m: compiler/error_util.m: compiler/hlds_out.m: compiler/prog_out.m: compiler/prog_util.m: compiler/rl_exprn.m: compiler/rl_gen.m: compiler/source_file_map.m: compiler/unused_args.m: library/io.m: library/rtti_implementation.m: library/type_desc.m: runtime/mercury_debug.c: runtime/mercury_deconstruct.c: runtime/mercury_stack_trace.c: Change `:' to `.' as module separator for output. compiler/mercury_to_mercury.m: compiler/prog_io_typeclass.m: As above. Fixed a bug where `.' was not being recognised as a module separator. doc/reference_manual.texi: Report the change. library/term_io.m: Ensure that infix `.' is written without surrounding spaces. tests/hard_coded/dot_separator.m: tests/hard_coded/dot_separator.exp: tests/hard_coded/Mmakefile: Test case added. |
||
|
|
a3819d359c |
Fix the handling of purity in the optimization and tabling passes.
Estimated hours taken: 15 Branches: main Fix the handling of purity in the optimization and tabling passes. Without this change tests/tabling/unused_args.m fails with inter-module optimization. compiler/purity.m: compiler/post_typecheck.m: Allow purity checking to be rerun on a single procedure without requiring an io__state. If the purity is worse (due to inlining a predicate with a `:- pragma promise_pure' declaration), add `promised_pure' or `promised_semipure' to the pred_info. compiler/hlds_out.m: compiler/hlds_pred.m: compiler/intermod.m: compiler/make_hlds.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/modules.m: compiler/prog_data.m: compiler/prog_io_pragma.m: compiler/purity.m: doc/reference_manual.texi: NEWS: Implement `:- pragma promise_semipure'. This is needed if an predicate marked `promised_pure' which calls impure predicates is inlined into a semipure predicate. compiler/inlining.m: Make sure the purity markers on the goal_infos are correct after inlining predicates which are promised pure. Export a predicate inlining__can_inline_proc which is used by deforestation to determine whether inlining a procedure will change the semantics or will break code generator invariants. compiler/deforest.m: Use the same method as inlining.m to work out whether a procedure can be inlined. Don't inline predicates which are promised pure because the extra impurity which will be propagated through the goal will stop deforestation working on the goal. compiler/simplify.m: Make sure the goal_info resulting from converting a singleton switch into a conjunction has the correct purity. compiler/table_gen.m: Make sure the purity markers on the generated goal_infos are correct. Make sure that call_table_gen goal features cannot be removed by optimization passes. Don't put unnecessary `impure' markers on calls to error/1. tests/debugger/loopcheck.exp: tests/debugger/retry.exp: Adjust the expected output. The change to ensure that `call_table_gen' goal features can't be removed alters the goal paths slightly. tests/invalid/impure_method_impl.m: Adjust the expected output now that predicates can be promised semipure. |
||
|
|
79d75acdb0 |
Add impure functions to Mercury, clean up the purity module somewhat,
Estimated hours taken: 30 Add impure functions to Mercury, clean up the purity module somewhat, fix some bugs in purity, update and expand the purity documentation, and re-organize the purity checks. Impure functions can be declared just like impure preds. However, they can only be called in an explicit unification preceeded by a purity level: impure X = some_impure_func(Y, Z) The bug fixed was the fact that closures of impure predicates were only being detected when using lambda syntax. Purity information was discarded and impure closures could be created like this: Pred = some_impure_pred You could then use this predicate anywhere you like without any purity declarations. compiler/hlds_module.m: Add get_pred_id pred which will return the pred_id of a predicate matching a given type. This is like get_pred_and_proc_id, but only gets the information we are interested in, and is semidet. We need a semidet version to handle cases where type inference cannot infer a type before the limit is reached, but we try to purity check this code. (The bug mentioned above was stopping us from purity checking the test case for this before). compiler/make_hlds.m: Check for "impure" unifications with expressions that are not function calls and issue appropriate error messages. When unravelling impure function call unifications, put the input parameter unifications (if any) before the actual call. Only mark the goal_info for the function call as impure. compiler/mercury_to_goedel.m: compiler/mercury_to_mercury.m: compiler/module_qual.m: compiler/prog_data.m: compiler/prog_io.m: compiler/prog_io_dcg.m: compiler/prog_io_goal.m: compiler/prog_util.m: Add purity information to unify goals. Don't assume unify goals are pure. compiler/purity.m: Allow impure functions. Check unification goals for purity (not just lambda unification). Check unifications that are transformed into calls to make sure the call is purity correct. Put purity checking logic into separate predicates. Use an enum to return different errors and warnings. (The last two changes make it much easier to see the similarities between checking goals and checking predicates for purity correctness). Give different error messages for impure functions (highlight that you need to use them in an explicit unification). Handle unknown predicate lookups (can occur when unifying with a higher order term whose type could not be inferred). Add a few comments delineating where changes might need to be made to make foreign code impure by default in future. compiler/notes/authors.html: Add Peter Schachte to the authors list. doc/reference_manual.texi: Document impure functions. Expand more on what impure predicates/functions can do. Explain the concept of worst purity, and use it to explain the "inferred purity"/"declared purity" concepts. Make it more explicit that only impure goals obey strict-sequential like semantics. tests/invalid/type_inf_loop.err_exp2: Fix this test case to reflect the new error message new that we check the purity of this code correctly (or rather, we correctly fail to be able to purity check this code). tests/hard_coded/Mmakefile: tests/hard_coded/purity.exp: tests/hard_coded/purity.m: tests/hard_coded/purity/Mmakefile: tests/hard_coded/purity/impure_func_t1.m: tests/hard_coded/purity/purity.m: tests/hard_coded/purity/runtests: Remove purity tests from the hard_coded directory, give it a sub-directory of its own. tests/invalid/Mmakefile: tests/invalid/purity.err_exp: tests/invalid/purity.m: tests/invalid/purity_nonsense.err_exp: tests/invalid/purity_nonsense.m: tests/invalid/purity/Mmakefile: tests/invalid/purity/impure_func_t2.err_exp: tests/invalid/purity/impure_func_t2.m: tests/invalid/purity/impure_func_t3.err_exp: tests/invalid/purity/impure_func_t3.m: tests/invalid/purity/impure_func_t4.err_exp: tests/invalid/purity/impure_func_t4.m: tests/invalid/purity/impure_func_t5.err_exp: tests/invalid/purity/impure_func_t5.m: tests/invalid/purity/impure_pred_t1.err_exp: tests/invalid/purity/impure_pred_t1.m: tests/invalid/purity/impure_pred_t2.err_exp: tests/invalid/purity/impure_pred_t2.m: tests/invalid/purity/purity.err_exp: tests/invalid/purity/purity.m: tests/invalid/purity/purity_nonsense.err_exp: tests/invalid/purity/purity_nonsense.m: tests/invalid/purity/runtests: Remove purity tests from the invalid directory, give it a sub-directory of its own. |
||
|
|
0156ecd793 |
Allow class methods to be impure or semipure.
Estimated hours taken: 6
Allow class methods to be impure or semipure. Previously any purity annotation
on a class method was ignored, and the method assumed to be pure. (We have
for some time caught the case of providing an impure implementation for
a (pure) class method, though).
compiler/prog_data.m:
Add purity to the information we store about each method.
compiler/prog_io_typeclass.m:
Record the declared purity of each method.
compiler/make_hlds.m:
For the predicate we generate corresponding to a method, add any
purity annotations that the method has.
compiler/check_typeclass.m:
Add the appropriate impurity marker to the predicate we generate for
each instance method.
compiler/purity.m:
Be careful not to spit out spurious purity warnings:
- Never warn about excessive impurity for a class methods.
(The body of the method is just class_method_call, which
never looks impure as far as it is concerned).
- Never warn about excessive impurity for class instance
method. The fact that a method is impure doesn't mean that
its instances need to be impure, and it would be excessive
to warn about it, seeing that there is no way for the user
to avoid it (other than actually making their implementation
impure...).
compiler/mercury_to_mercury.m:
Print out method purity in interface files.
compiler/module_qual.m:
compiler/equiv_type.m:
Handle the fact that we now store purity info for class methods.
tests/hard_coded/typeclasses/impure_methods.{m,exp}:
A test case for this change.
tests/hard_coded/typeclasses/Mmakefile:
Turn this change on.
tests/invalid/impure_method_impl.{m,err_exp}:
A test case for invalid use of impurity and class methods
tests/invalid/Mmakefile:
Turn this change on.
|