Message Boards Message Boards

10
|
3765 Views
|
0 Replies
|
10 Total Likes
View groups...
Share
Share this post:

Bug with Block & Lookup: Scope Variable Leak.

Posted 6 years ago

After debugging a large chunk of code, I could identify this MWE.

ClearAll@test
test[var_String]:= Block[{association},
    association = <|"x"-> <|"key01"-> "ok"|>|>[var];
    Lookup[association,"key01",{}]
]

If I evaluate:

test["x"]
test["y"]
test["x"]

I get an error evaluating the last test["x"]. What is very strange, I expected to find an error just in the evaluation of test["y"].

The same error does not occur if we change from Block to Module. In the Block case, we have some sort of unexpected scope leak. Looks like a bug in Lookup.

Tested in Mathematica version 11.3
Cross post in Stack Exchange

POSTED BY: Rodrigo Murta
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract