Bug? Variable name not recognised in Obfuscate and compile code

Simon Kinsey v2

Member
Licensed User
Longtime User
I keep getting an unrecognised variable name error when I try to compile and obfuscate my code.

I have compiled the code for release many times without problems. When obfuscating, it won't get past the following code in a class file called Scoring

B4X:
Public Sub Score_msg As String
Dim Msg As String
Msg = C_msg & " £"
Msg = Msg & Round(Score)
Msg = Msg & C_unit
Return Msg

End Sub

Compilation says that Msg is not a recognised variable name. I tried changing the variable name to X without success. I tried removing the underscore from the method name, and returning a string literal instead of the variable value. It makes no difference - even a string literal is an unrecognised variable name. The variables beginning with C_ are instance variables.

If I remove this whole routine from Public Sub to End Sub, I get the same error message at the Return statement in the code below it:

B4X:
Public Sub Low_funds As Boolean
Return (Score < Const.WARNING )
End Sub

This is frustrating as it is the last compile I need before releasing the program. Any suggestions on what I can do?
 

Simon Kinsey v2

Member
Licensed User
Longtime User
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.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…