Commit Graph

6 Commits

Author SHA1 Message Date
Zoltan Somogyi
3dc4babb24 Update the style of more test cases.
And update expected output files for changes in line numbers.
2021-07-27 13:29:46 +10:00
Zoltan Somogyi
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.
2015-02-16 12:32:18 +11:00
Julien Fischer
73e40cd5e2 Make it an error for the (promised) purity of a foreign clause to disagree
Estimated hours taken: 6
Branches: main, release

Make it an error for the (promised) purity of a foreign clause to disagree
with the declared purity of the corresponding predicate or function
declaration.  We only perform this check in the absence of a
promise_{pure,semipure} pragma for the predicate or function.

Previously this situation was sometimes picked up by purity analysis but not
in all cases.  For example, if a predicate was declared impure but the
foreign_proc was promised pure it wasn't reported.  In that particular case
it was a problem because if the foreign_proc did not have any outputs, then
simplify.m might have optimised its body away (which is how I noticed this).

compiler/add_pramga.m:
	In the absence of promise_{pure,semipure} pragmas emit error messages
	about mismatches between the declared purity of a procedure and the
	(promised) purity of a foreign clause for it.

compiler/mode_errors.m:
	Fix a typo in an error message: s/becaise/because/

compiler/purity.m:
	Fix a bug reported by Ian. Inconsistent purity annotation were being
	treated as both a warning and an error.  Make it into an error.

library/private_builtin.m:
library/solutions.m:
	Delete bogus purity promises from foreign_proc attributes reported by
	the new check.

tests/invalid/Mmakefile:
tests/invalid/foreign_purity_mismatch.{m,err_exp}:
	Test case for the new error.

compiler/simplify.m:
compiler/prog_io_pragma.m:
	Fix some formatting.

tests/*/*:
	Fix purity errors picked up by the new check.
2006-07-10 04:41:00 +00:00
Julien Fischer
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.
2005-04-12 07:58:24 +00:00
Peter Ross
4c71c5db87 Gets the tests in tests/invalid working in the il grade.
Estimated hours taken: 3
Branches: main

Gets the tests in tests/invalid working in the il grade.

compiler/options.m:
	Add a new developer option, --no-automatic-intermodule-optimization.
	This is used to turn off intermodule optimization in the
	tests/invalid directory so that the error messages are no
	longer generated during the --make-optimization-interface
	process.

compiler/handle_options.m:
	Test automatic-intermodule-optimization when determining
	whether to turn intermodule optimization on in the il grade.

tests/invalid/Mercury.options:
tests/invalid/purity/Mercury.options:
	Add --no-automatic-intermodule-optimization.

tests/invalid/foreign_singleton.err_exp2:
tests/invalid/foreign_type_2.err_exp2:
tests/invalid/pragma_c_code_dup_var.err_exp2:
tests/invalid/pragma_c_code_no_det.err_exp2:
	Add a second expected error message for non C backends.

tests/invalid/impure_method_impl.m:
tests/invalid/multimode_missing_impure.m:
tests/invalid/multimode_syntax.m:
tests/invalid/pragma_c_code_no_det.m:
tests/invalid/purity/impure_func_t2.m:
tests/invalid/purity/impure_func_t3.m:
tests/invalid/purity/impure_func_t4.m:
tests/invalid/purity/impure_func_t5.m:
tests/invalid/purity/impure_func_t7.m:
tests/invalid/purity/impure_pred_t1.m:
tests/invalid/purity/impure_pred_t2.m:
tests/invalid/purity/purity.m:
	Add Mercury implementations of foreign_code predicates.
2002-11-07 16:17:09 +00:00
David Jeffery
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.
2000-03-27 05:08:27 +00:00