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
classProgram{staticvoidMain(string[]args){// The example code is a bit contrived but the problem appears in real code.IEnumerable<int>results=fromarginargsletparsedArg=ParseString(arg)// ParseString returns `string?`. However, parsedArg is considered a `string`, not a `string?`, which you can see when inspecting the variable in VS.//where !(parsedArg is null) // Removal of this line should cause a CS8604 error below, but it doesn't.selectint.Parse(parsedArg);string?thing=null;ParseString(thing);// As a sanity check, this does cause a CS8604.}privatestaticstring?ParseString(stringinput){// Imagine this function sometimes returns null and sometimes it doesn't.returnnull;}}
Expected Behavior: the parsedArg range variable is considered a string?, and removal of the where clause causes a CS8604 (Possible null reference argument for parameter) warning in the line below it.
Actual Behavior: The variable is considered a string and no warnings are emitted.
The text was updated successfully, but these errors were encountered:
I think the part where parsedArg has not-null flow state is a bug, and the part where the where clause is expected to change the flow state is a feature request in the vein of dotnet/csharplang#8383 and #39586
Version Used: 3.4.0-beta4-19569-03 (82f2e25)
Steps to Reproduce:
Expected Behavior: the
parsedArg
range variable is considered astring?
, and removal of thewhere
clause causes a CS8604 (Possible null reference argument for parameter) warning in the line below it.Actual Behavior: The variable is considered a
string
and no warnings are emitted.The text was updated successfully, but these errors were encountered: