mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
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.
6 lines
63 B
Plaintext
6 lines
63 B
Plaintext
17
|
|
(baz) !.Y = -200
|
|
(BazFoo) !.Y = 700
|
|
(BazBar) !.Y = 700
|
|
-200
|