You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
namespaceScratch{static{// Error! ("The out parameter `out` must be assigned to before control leaves the current method")privatestaticboolA(intvalue,outint@out){switch(value){default:returnB(out@out);}}privatestaticboolB(outint@out){@out=123;returntrue;}}}
The code above fails to compile with the message The out parameter 'out' must be assigned to before control leaves the current method. This error is a false positive since @out is guaranteed to be assigned. Modifying the two functions to return void (shown below) compiles successfully:
namespaceScratch{static{// No error!privatestaticvoidA(intvalue,outint@out){switch(value){default:B(out@out);}}privatestaticvoidB(outint@out){@out=123;}}}
Here's one additional example that's functionally identical to the first example, but compiles successfully:
namespaceScratch{static{// No error!privatestaticboolA(intvalue,outint@out){switch(value){default:{B(out@out);returntrue;}}}privatestaticvoidB(outint@out){@out=123;}}}
The text was updated successfully, but these errors were encountered:
I have run into a similar issue.
It only happens when the code is inside a switch case.
staticclassProgram{staticvoidTest(outintoutput){switch(1){default:if(false){output=1;return;}else{//output = 1; // Works if this is enabled}output=1;return;}}}
The code above fails to compile with the message
The out parameter 'out' must be assigned to before control leaves the current method
. This error is a false positive since@out
is guaranteed to be assigned. Modifying the two functions to returnvoid
(shown below) compiles successfully:Here's one additional example that's functionally identical to the first example, but compiles successfully:
The text was updated successfully, but these errors were encountered: