Hi @Anonymous,
I suspect the issue should be related with the Variable initialization.
The code should work when the switch function executes, and should be no errors, which means the Variables are initialized successfully by the UpdateContext function.
While under edit mode, there is no data holded in the variables actually, so when using variable in expression, there might be logic errors shown out.
Workable way that I can suggest is, try to execute the expression and assign a value to each of the variables, this should clear the error.
Regards,
Michael