fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Incorrect warning XS2019 02 Apr 2021 13:10 #17936

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 894
  • I usually do not care much about warnings, but I thought, why not deal with it.

    Currently I have 2 warnings like this:

    warning XS0219: The variable 'lFound' is assigned but its value is never used

    But lFound is isused!

    Local lFound As Logic

    oDBF:=DbServer{cDataPath+"tel.dbf",TRUE,FALSE}
    If !empty(cSearch)
    oDBF:Seek(cSearch)
    Else
    lFound:=oDBF:GoTo(Int(nRecordnr))
    ENDIF


    Same for the other error. If I remove the so called "never used" variable declaration I get:


    Error XS0103 The name 'lFound' does not exist in the current context

    What's wrong with this warning?


    Dick

    Please Log in or Create an account to join the conversation.

    Incorrect warning XS2019 02 Apr 2021 13:35 #17938

  • robert's Avatar

  • robert


  • Posts: 2118
  • Dick,
    The variable is used indeed. You are assigning the result of GoTo() but after the assignment you are not using it. The compiler warns you about that fact.
    So you could remove the variable AND the assignment.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Incorrect warning XS2019 03 Apr 2021 18:24 #17944

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 894
  • Hello Robert,

    You're right indeed.

    The reason I use this is often that I know that there is a return value I can use if I want. So I leave it as it is, with the warning.

    But this gives the same warning and it's definitely used I'd say:

    LOCAL cResult AS STRING
    cResult:=Self:SqlIssueQuery(cWb,cCs,cDb,cQuery,cQuery2,cQuery3,cQuery4,cQuery5,cVolgQuery,cRecords) // Execute query on webservice
    If empty(cResult)
    LogEvents("....."0
    Endif


    Dick

    Please Log in or Create an account to join the conversation.

    Incorrect warning XS2019 03 Apr 2021 22:54 #17945

  • Chris's Avatar

  • Chris


  • Posts: 2434
  • Hi Dick,

    What is the exact warning message? And can you please post the whole code of this entity?
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Incorrect warning XS2019 06 Apr 2021 13:04 #17949

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 894
  • Hello Chris,

    The warning was XS2019 (see subject) and the code was as provided...but on further investigation that code was not were the warning popped up but one method further were cResult was also assigned, but not used.

    The reason that it is easy to overlook this is because of one of the countless flaws of VS. In the error- or warninglist it does not tell which method the warning is in, unlike in VO. In VO I would have seen the method name, doubleclicked the method, opened that method alone and seen at once that the variable was not actually used. In VS you do not see that, I search for the variable and see, in the results, a correct assignment- but in another method.

    Dick

    Please Log in or Create an account to join the conversation.

    Incorrect warning XS2019 06 Apr 2021 17:58 #17954

  • Chris's Avatar

  • Chris


  • Posts: 2434
  • Hi Dick,

    Indeed that's not ideal, but I know another .Net IDE that does show you the entity that the warning/error is referring to :)
    But also in VS, when you double click on the warning, the file will be opened and the cursor will be placed in the exact spot of the warning/error, so it should be obvious then what the problem is. If that's not happening, then it is a bug, please report this if you see some problem like that.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Incorrect warning XS2019 06 Apr 2021 18:21 #17957

  • ic2's Avatar

  • ic2

  • Topic Author


  • Posts: 894
  • Hello Chris,

    Chris wrote: Indeed that's not ideal, but I know another .Net IDE that does show you the entity that the warning/error is referring to :)/quote]

    I assume you mean Xide :)which of course is much better in many respects than VS but unfortunately I need the also a a WPF editor, which is only in VS, a pretty crappy one but what else can you expect from VS.

    Chris wrote: But also in VS, when you double click on the warning, the file will be opened and the cursor will be placed in the exact spot of the warning/error, so it should be obvious then what the problem is. If that's not happening, then it is a bug, please report this if you see some problem like that.


    Sure that works (even in VS).. But as all code is in the same editor it is also easy to mistakenly end up in another method when you search using the variable from the error.

    VS is also one of the few products where I can easily skip 10 or more updates without missing one of changes/additions mentioned for that update. In the past few years I can actually only think of only one useful addition: that CodeLens was added to the Community version, and that doesn't even work in X# :(

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.
    • Page:
    • 1