Bug? error on local var when a function has same name

pappicio

Active Member
Licensed User
Hi, this code give error on compilation, while in test compilation is ok!
B4X:
Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")
   example
End Sub

Sub example
   Dim error As Boolean = False
   
   Dim aaa As String=""
   If aaa.Trim = "" Then
     error = True
   End If
   If error = True Then
     Msgbox("error...","")
     Return
   End If
End Sub
Sub error As Boolean
   Dim a As Int=0
   If a=1 Then
     Return True
   End If
   Return False
End Sub
while if I change local var in 'example' sub like: errorx, all is ok in compilation mode.
 

pappicio

Active Member
Licensed User
Yes, I know, but in bigger project, I cannot know where the problem is, this is a little part o a bigger project... for me is a kind of bug, cos the compiler should advice me about the name used in local var and in global function, and, try you, to compile this little project, no advice about, only a java error about a ";" error on compiling created java code.
 

Cableguy

Expert
Licensed User
It's not a BUG! in all development languages, developers are sensed to not use same name to views, variables and subs.
B4A is a new development tool when compared to other tools out there, and a huge effort has been and is being done to make error messages more and more self explanatory. Still, it's a work in progress...

I would suggest to place this as a WISH to have better error reporting ( wich Erel strives to give us) and not as a bug.
A bug implies that something is not functioning as described or expected thou the code is correct...
 
Last edited:

pappicio

Active Member
Licensed User
I don't know, if is a bug or something else, I onsy see that that kind of anomaly, cannot be find in an easy way, if appen in a big module, where I forgot the name of a sub (function) and compiling appear that error..... I only programmed in vb 6, and don't remember if a kind of situation gave me an adverticment or not.
See you and thanks all of you, for your answers.
 
Top