Bug? Code compiles in release, fails in debug mode

agraham

Expert
Licensed User
Longtime User
I normally don't don't use debug mode but rely on #Bridgelogger: True logging to track program flow. This time I thought it might track me through a complicated set of conditionals so I enabled debug mode, and the working code promptly failed to compile
B4A Version: 10.0
Java Version: 8
Parsing code. (0.04s)
Building folders structure. (0.02s)
Compiling code. Error
Error compiling program.
Error description: Current declaration does not match previous one.
Error occurred on line: 353
For Each name As String In childlist
Word: _ref
The error is in this Sub
B4X:
Sub GetChildren(dv As DraggableView, children As List)
    Dim v As View = dv.lblView
    Dim vi As ViewInfo = v.Tag
    Dim childlist As List = vi.ViewChildren
    children.AddAll(childlist)
    For Each name As String In childlist ' <--------------- here
        Dim childdv As DraggableView = ViewsNamesMap.Get(name.ToLowerCase)
        GetChildren(childdv, children)
    Next   
End Sub
If I change variable name to aname the compilation failure moves to a similar construct in a different Sub
B4X:
        For Each name As String In allchildren ' <--------------- here
            If name.ToLowerCase = parentname Then
                IsChild = True
            End If
        Next
If I change variable name to bname the compilation now succeeds. It turns out that I unwittingly have a
B4X:
    Dim name As String
in that modules' Sub Class_Globals :(
but the editor Intellisense does not pick up the type redeclaration of the name when used as a loop variable whereas it does elsewhere!
 

agraham

Expert
Licensed User
Longtime User
There are performance reasons behind it.
Performance reasons for not detecting in Intellisense? Isn't it just another declaration that can be checked?
there is really no good reason to use a global variable for the iterator.
I know, it was a mistake. As the code has grown I forgot I had used it as a global. Normally a local redeclaration is picked up by Intellisense.
 

agraham

Expert
Licensed User
Longtime User
Sorry, I seem to be totally failing to get my point across. If I redim a global variable as a different type the Intellisense in the IDE warns me, unless it seems, it is a loop variable when it doesn't.

Ok scrub that, I'm getting confused with something else. Sorry :( I think I'd better give up and go out in the sun to chip up some trees I cut down a few days ago.

EDIT: In case you think I made a typo I do mean "chip" and not "chop". Anything too small too log up goes through the chipper, is placed in a pile to rot for a year or two then used as mulch.
 
Last edited:
Top