Files
mercury/tests/hard_coded/sv_nested_closures.exp
Julien Fischer a652b9bc4c Fix a bug with state variables and closures nested more than one level deep
Estimated hours taken: 3
Branches: main, release

Fix a bug with state variables and closures nested more than one level deep
reported by valery@freesurf.fr.  The problem was that the map that kept track
of which state variables came from the scope enclosing a lambda expression
(and are hence read-only inside the lambda expressiong), was being incorrectly
overwritten when a nested lambda expression was encountered.  The fix is to
merge the set of state variables from the body of the lambda with those from
the enclosing scope before processing the nested lambda.  (Actually in order
to ensure that we get things correct if the same variable is used in multiple
scopes we overlay the maps rather than merge them.)

compiler/state_var.m:
	When preparing to process a lambda expression don't throw away any
	state variable mappings from enclosing scopes.

tests/hard_coded/Mmakefile:
tests/hard_coded/sv_nested_closures.{m,exp}:
	Test case for the above.
2006-06-20 08:48:51 +00:00

6 lines
63 B
Plaintext

17
(baz) !.Y = -200
(BazFoo) !.Y = 700
(BazBar) !.Y = 700
-200