Skip to content
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

Fix ElseIfStatement double-evaluation in awaited context #485

Merged
merged 1 commit into from
Apr 1, 2022

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Apr 1, 2022

This code in awaited context check caused elseIf.WriteToAsync to always start writing, even when it should be only started if condition is true:

if (!elseIfConditionTask.IsCompletedSuccessfully)
{
    var writeTask = elseIf.WriteToAsync(writer, encoder, context);
    return AwaitedElseBranch(elseIfConditionTask, writeTask, writer, encoder, context, i + 1);

Parametrized test case to test async and non-async paths the get some red tests and then fixed. Now passing the elseIf and write task is retrieved, if needed.

We found out this when running on Linux against sync code, which was quite curious, on Windows it always worked.

@sebastienros sebastienros merged commit f2f99f9 into sebastienros:main Apr 1, 2022
@lahma lahma deleted the fix-double-write-elsif branch April 1, 2022 19:29
@lahma
Copy link
Collaborator Author

lahma commented Apr 1, 2022

@sebastienros this bug was somewhat nasty and unpredictable (template writing both elsif and else content), should there be a new release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants