mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-17 23:05:21 +00:00
Estimated hours taken: 11 Branches: main Fix the problems with mutable declarations and sub-modules by making sure that the relevant information is written out in the private interface files. Fix a bug where mutable variables were not being initialised with their declared intial value. The problem was that the compiler was optimizing away the body of the automatically generated predicate that was setting the initial value. We now make such predicates impure to prevent this. In order to support the above, accept `:- intialise' declarations that specify impure predicates, provided that the declaration in question was generated by the compiler. It is still an error for the user to specify such declarations. Fix some other problems with mutable declarations. compiler/modules.m: Do not write `:- mutable' declarations out to private interface files, instead write out the predicate and mode declarations for the access predicates. Remove some old XXX comments about mutables that are no longer relevant. compiler/make_hlds_passes.m: Don't add the export pragmas for initialise declarations during pass 2. For some reason we were doing this during pass 2 and again during pass 3. Make the intialise predicates for mutable variables impure in order to prevent the compiler from optimizing them away Fix origin fields that were being set incorrectly during the mutable transformation. compiler/prog_mutable.m: New module. Shift some code from make_hlds_passes to here, since modules.m also needs access to it. compiler/parse_tree.m: Include the new module. compiler/notes/compiler_design.html: Mention the new module. tests/hard_coded/sub-modules/Mmakefile: tests/hard_coded/sub-modules/mutable_parent.m: tests/hard_coded/sub-modules/mutable_child.m: tests/hard_coded/sub-modules/mutable_grandchild.m: tests/hard_coded/sub-modules/mutable_parent.exp: Test case for mutables and sub-modules. tests/hard_coded/not_in_interface.m: tests/hard_coded/not_in_interface.err_exp: Test for ordering problems between mutable and initialise declarations when emitting errors about items that should not occur in module interfaces. This can happen if the item's origin field is incorrectly set.