Version 4.0 of B4A helped, because the error messages from the compiler are more specific.
I have found the problem. If a variable name or function includes a reserved word preceded by an underscore, then the compilere treats the reserved word as a variable name. So, in the function get_rect it reports that it cannot find the variable _rect.
I removed underscores from functions including reserved word names, and it now compiles fine.