Incorrect warning XS2019

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Incorrect warning XS2019

Post by ic2 »

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
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Incorrect warning XS2019

Post by robert »

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
robert@xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Incorrect warning XS2019

Post by ic2 »

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
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Incorrect warning XS2019

Post by Chris »

Hi Dick,

What is the exact warning message? And can you please post the whole code of this entity?
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Incorrect warning XS2019

Post by ic2 »

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
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Incorrect warning XS2019

Post by Chris »

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.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Incorrect warning XS2019

Post by ic2 »

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
Post Reply