"Remove Unused Variables" incorrectly removes variables that have a shared scope

I guess this is a bug: (UIPath Studio version: 2019.10.4)


“Remove Unused Variables” incorrectly removes variables from processes with activities that run in the same scope as the parent (e.g. For Each)

Steps to reproduce:

  • Open the attached process:
    Main.xaml (5.4 KB)
  • (Confirm that it runs: it should yield a B)
  • Select: Remove Unused Variables


The process breaks (escalation marks) with:

Main.xaml: Compiler error(s) encountered processing expression “Dict(item)”.
‘Dict’ is not declared. It may be inaccessible due to its protection level.