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
Incorrect warning XS2019
Incorrect warning XS2019
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
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
The Netherlands
robert@xsharp.eu
Incorrect warning XS2019
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
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
Incorrect warning XS2019
Hi Dick,
What is the exact warning message? And can you please post the whole code of this entity?
What is the exact warning message? And can you please post the whole code of this entity?
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Incorrect warning XS2019
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
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
Incorrect warning XS2019
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.
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
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Incorrect warning XS2019
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.
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.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.
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