you are in a Try/Catch block, and if your code fails with an exception other than the one you are catching, before SR is initialized, you call the :Close() method on a not initialized object.
This sort of compiler warning helps me a lot!
yep, i hear you.
But what to do? As far as i saw, i have to provide the input stream at instantiation of the object, so when moving instantiation out of the block i'm unsafe, in case the stream call fails. OTOH, reminds me why i don't like the concept of writing constructors which do more than producing an object..
Somewhat contradictory to the "assign vals to property in the constructor call in the other thread.
BTW, i tried the new conditional syntax oSR?:Close() to no avail, not sure what to make of that..
Finally, in my defense: this is not my code, but the transposition of VB source
not sure what use a := Null has? If both instantiation paths in try and catch fail, the final :close would crash, nevertheless.
I think the ?: syntax prevents a crash...
But i wonder: i get no warning in the ResponseData := SR:ReadToEnd() lines, probably because the instantiation is "inside" the same block. What means, the real warning occurs because the compiler can't feather that SR exists as either the try or the catch path WILL be executed.
In a certain way the inverse situation of "unreachable code"
Not sure if this qualifies as a bug or not...
Anyway, interesting discussion,
thx for you time!