Message Boards Message Boards

Bug with Block & Lookup: Scope Variable Leak.

GROUPS:

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
Answer
7 months ago

Group Abstract Group Abstract