File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
1010### Fixed
1111
12+ * [ Python] Fix missing ` await ` on else branch of ternary expressions in async closures (by @dbrattli )
1213* [ Beam] Fix ` |> ignore ` on cross-module Emit calls generating variable bindings that shadow Emit case-clause variables (by @dbrattli )
1314* [ Beam] Fix ` containsIdentRef ` not checking ` Call ` ThisArg (by @dbrattli )
1415* [ All] Fix CLI color not resetting after error messages (fixes #3755 ) (by @MangelMaxime )
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
1010### Fixed
1111
12+ * [ Python] Fix missing ` await ` on else branch of ternary expressions in async closures (by @dbrattli )
1213* [ Beam] Fix ` |> ignore ` on cross-module Emit calls generating variable bindings that shadow Emit case-clause variables (by @dbrattli )
1314* [ Beam] Fix ` containsIdentRef ` not checking ` Call ` ThisArg (by @dbrattli )
1415* [ JS/TS] ` StringEnum ` now respect ` CompiledValue ` and ` CompiledName ` (by @shayanhabibi )
Original file line number Diff line number Diff line change @@ -816,7 +816,7 @@ module PrinterExtensions =
816816 | Name ex -> printer.Print( ex)
817817 | Await ex ->
818818 printer.Print( " await " )
819- printer.Print ( ex)
819+ printer.ComplexExpressionWithParens ( ex)
820820 | Yield expr ->
821821 printer.Print( " yield" )
822822
Original file line number Diff line number Diff line change @@ -199,3 +199,23 @@ let ``test async returns in try-with are awaited`` () =
199199
200200 let result2 = wrapper true |> fun tsk -> tsk.GetAwaiter() .GetResult()
201201 equal - 1 result2
202+
203+ // Regression: closure with let binding before if/else returning Task emits ternary;
204+ // both branches of the ternary must be awaited.
205+ let asyncNone () : Task < int option > = Task.FromResult None
206+
207+ let makeClosure ( flag : bool ) =
208+ let captured = flag
209+ fun ( value : int ) ->
210+ let x = value + 1
211+ if captured then Task.FromResult( Some x) else asyncNone ()
212+
213+ [<Fact>]
214+ let ``test async ternary in closure awaits both branches`` () =
215+ let fn = makeClosure true
216+ let result = fn 41 |> fun tsk -> tsk.GetAwaiter() .GetResult()
217+ equal ( Some 42 ) result
218+
219+ let fn2 = makeClosure false
220+ let result2 = fn2 41 |> fun tsk -> tsk.GetAwaiter() .GetResult()
221+ equal None result2
You can’t perform that action at this time.
0 commit comments