-
Notifications
You must be signed in to change notification settings - Fork 783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ignore keyword giving unexpected results #15880
Comments
|
As @kerams mentioned, since You probably want |
Thanks for the replies. That's interesting. So why does this work? "Done" |> System.Console.WriteLine |> ignore |
Due to piping, first you pass string |
Should we warn against ignoring a function? |
I would say not compiler itself, since, well, ignore is just a function. Would need special treatment from the compiler in this case. |
@vzarytovskii I remember someone proposed a |
This works as expected. But it would be a good use case for an analyzer that could warn users that this code probably won't do what they expect. Or that it doesn't make sense to ignore functions/methods. |
Repro steps
Expected behavior
The
IAsyncEnumerable
returned byReadAllAsync()
should behave like a finite set of 2 elements and come to an end.Actual behavior
The
IAsyncEnumerable
never ends. "Done" is never written to the stdout. TheChannel
isn't marked asclosed
.Workaround
Swapping to
channel.Writer.Complete()
will cause this code to terminate.I am new to F#, so this might be my ignorance, but my understanding is that
Complete()
andComplete |> ignore
should be equivalent in this case. The only odd thing aboutchannel.Writer.Complete
, that I can see, is that it takes an optional parameter. Have I missed something obvious here? I couldn't find any mention of this type of behaviour while everything I've read suggests that|> ignore
is the correct, idiomatic syntax.The text was updated successfully, but these errors were encountered: