Mercury Bugs - mercury
View Issue Details
0000143mercuryBugpublic2010-04-09 17:292010-05-20 19:02
Reporterrafe 
Assigned Tojuliensf 
PrioritynormalSeverityfeatureReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000143: ':- initialise' directives not being respected.
DescriptionCompile the attached foo.m file and run it. It should output

map([(1 -> BAZ), (2 -> BAR), (3 -> BAZ)])

but unless the call to init_foo/2 in main/2 is uncommented out you get this:

map([(1 -> baz), (2 -> bar), (3 -> baz)])

The ':- initialise init_foo/2.' directive is not being respected.

This is a problem since I was hoping to use this functionality to debug the IC solver.
TagsNo tags attached.
Attached Files? foo.m (984) 2010-04-09 17:29
https://bugs.mercurylang.org/file_download.php?file_id=100&type=bug

Notes
(0000262)
juliensf   
2010-04-09 17:53   
This is not a bug IMO. The initialiser is being called, you can see this if you get it to print something
out. The problem is that the pretty-printer stores its state in a set of mutables

From section 9.6 of the reference manual:

For the purposes of determining when mutables are assigned their initial values, the expression ‘initial_value’ behaves as though it were a predicate specified in an ‘initialise’ directive.

From section 9.4 of the reference manual:

Initialisation predicates within a module are executed in the order in which they are specified, although no order may be assumed between different modules or sub-modules.

What is happening here, is that your initialiser is being called and the its effects are being
overwritten by the initialisation of the mutables in the pretty_printer module in the stdlib.
(0000264)
juliensf   
2010-05-20 19:02   
Fixed.

Issue History
2010-04-09 17:29rafeNew Issue
2010-04-09 17:29rafeFile Added: foo.m
2010-04-09 17:53juliensfNote Added: 0000262
2010-04-09 17:53juliensfStatusnew => feedback
2010-05-20 19:02juliensfNote Added: 0000264
2010-05-20 19:02juliensfStatusfeedback => resolved
2010-05-20 19:02juliensfResolutionopen => fixed
2010-05-20 19:02juliensfAssigned To => juliensf