Bug? Compile time object cast error

Discussion in 'Bugs & wishlist' started by ANC Software, May 7, 2018.

  1. ANC Software

    ANC Software New Member Licensed User


    I have a sub which helps me to read map objects as follows:

    Sub GetTextItem(Rec As Map, FieldName As StringAs String
    Dim ret As String
    End Try
    Return ret
    End Sub
    The problem is that if I call GetTextItem passing a List object instead of a Map object, the compiler doesn't warn me about the error, but it will be thrown at Runtime.


    dim ls as List

    'add some items

    log( GetTextItem(ls, "DUMMY") ) ' this should be handled by the compiler
    Further, I noticed that in this case the Application_Error didn't fire.

    Any help is much appreciated, thank you.
  2. Erel

    Erel Administrator Staff Member Licensed User

    In some cases the compiler will show a warning for wrong types, however there are many cases where the compiler doesn't know whether casting is allowed so it tries to cast. In such cases the error will happen at runtime.

    Make sure to run your app in release mode. If it doesn't work then please start a new thread in the questions forum.
  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