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

Discussion in 'Bugs & wishlist' started by pappicio, Feb 15, 2015.

  1. pappicio

    pappicio Active Member Licensed User

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

    Sub example
    Dim error As Boolean = False
    Dim aaa As String=""
    If aaa.Trim = "" Then
         error = 
    End If
    If error = True Then
    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.
  2. NJDude

    NJDude Expert Licensed User

    You should change the name of the "error" variable to something else since you have a sub with the same name.
    thedesolatesoul likes this.
  3. pappicio

    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.
  4. Cableguy

    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: Feb 16, 2015
    stevel05 and thedesolatesoul like this.
  5. Erel

    Erel Administrator Staff Member Licensed User

    Don't worry. The semantics are not really important. I've already added it to the list of planned fixes...
    Cableguy and stevel05 like this.
  6. Cableguy

    Cableguy Expert Licensed User

    A WISH soon to became true...
  7. pappicio

    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.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice