In the example the construct in the TestYes() function works, but the TestNo() fails with the above error.
I also looked at the compiled code generated by the compiler (see attached), and it seems that the bad function tries to load the variable's value from a different stack location (see line 9), which could explain why the interpreter finds a bad value.
(This is pure speculation since I know close to nothing about the Gambas bytecode, but I thought it might help)
I've actually found a fix to evaluate the expression before entering the WITH block.
But since I'm not confident enough with the compiler's internals to commit it directly, I put it in a separate temporary branch on the git repository.
The merge request can be found here : https://gitlab.com/prokopyl/gambas/merge_requests/1/diffs