xsharp.eu • XS0165 Use of unassigned local variable
Page 1 of 1

XS0165 Use of unassigned local variable

Posted: Thu Dec 21, 2023 9:58 pm
by ic2
Another warning which seems incorrect to me:

Code: Select all

Begin Sequence
bErrorHandler := {|oError| _Break(oError)}
bLastHandler := ErrorBlock(bErrorHandler)
oFTP:=FtpAX{}
......
oFTP:Close()

Recover
oFTP:Close() // This is the warning line
End
In the forelast line I get XS0165 Use of unassigned local variable oFTP

But the variable is assigned, and I'd say the FTP connection can just as well be closed in a Recover situation as it is done just a few lines up.

Technically I understand that the assignment of the error handler could cause an exception meaning it reaches the Recover + oFTP:Close before it is assigned.
But practically, this shouldn't be something to warn for I would say?

Dick

Re: XS0165 Use of unassigned local variable

Posted: Thu Dec 21, 2023 10:11 pm
by Chris
Hi Dick,

Why not? It is very possible indeed that the var did not get assigned before the error happened. What could be better though is the error message, instead of "Use of unassigned variable", it would be more correct to say "Use of possibly unassigned variable".

Re: XS0165 Use of unassigned local variable

Posted: Fri Dec 22, 2023 8:01 am
by robert
Chris,
I'll change the warning message

Robert