Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Compiler/Interactive/fsi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,8 @@ type internal FsiDynamicCompiler
if tcConfig.printAst then
for input in declaredImpls do
fprintfn fsiConsoleOutput.Out "AST:"
fprintfn fsiConsoleOutput.Out "%+A" input
let layout = DebugPrint.implFileL input
fprintfn fsiConsoleOutput.Out "%s" (LayoutRender.showL layout)
#endif

diagnosticsLogger.AbortOnError(fsiConsoleOutput)
Expand Down
5 changes: 4 additions & 1 deletion src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11225,13 +11225,16 @@ let mkOptimizedRangeLoop (g: TcGlobals) (mBody, mFor, mIn, spInWhile) (rangeTy,
| RangeCount.PossiblyOversize calc ->
calc (fun count wouldOvf ->
buildLoop count (fun mkBody ->
// mkBody creates expressions that may contain lambdas with unique stamps.
// We need to copy the expression for the second branch to avoid duplicate type names.
let mkBodyCopied idxVar loopVar = copyExpr g CloneAll (mkBody idxVar loopVar)
mkCond
DebugPointAtBinding.NoneAtInvisible
mIn
g.unit_ty
wouldOvf
(mkCountUpInclusive mkBody (tyOfExpr g count))
(mkCompGenLetIn mIn (nameof count) (tyOfExpr g count) count (fun (_, count) -> mkCountUpExclusive mkBody count))))
(mkCompGenLetIn mIn (nameof count) (tyOfExpr g count) count (fun (_, count) -> mkCountUpExclusive mkBodyCopied count))))
)

let mkDebugPoint m expr =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let f0 f = [|for n in 1..10 do f (); yield n|]
let f0 f = [|for n in 1..10 do f (); yield n|]
let f00 f g = [|for n in 1..10 do f (); g (); yield n|]
let f000 f = [|for n in 1..10 do f (); yield n; yield n + 1|]
let f0000 () = [|for n in 1..10 do yield n|]
Expand Down Expand Up @@ -42,3 +42,8 @@ let f29 f g = [|let y = f () in let z = g () in for x in 1..2..10 -> x + y + z|]
let f30 f g = [|let y = f () in g (); for x in 1..2..10 -> x + y|]
let f31 f g = [|f (); g (); for x in 1..2..10 -> x|]
let f32 f g = [|f (); let y = g () in for x in 1..2..10 -> x + y|]

// https://github.com/dotnet/fsharp/issues/19156
let f33 (start : int) (finish : int) f = [|for _ in start..finish -> id id ()|]
let f34 (start : int64) (finish : int64) f = [|for _ in start..finish -> id id ()|]
let f35 (start : uint64) (finish : uint64) f = [|for _ in start..finish -> id id ()|]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let f0 f = [for n in 1..10 do f (); yield n]
let f0 f = [for n in 1..10 do f (); yield n]
let f00 f g = [|for n in 1..10 do f (); g (); yield n|]
let f000 f = [for n in 1..10 do f (); yield n; yield n + 1]
let f0000 () = [for n in 1..10 do yield n]
Expand Down Expand Up @@ -42,3 +42,8 @@ let f29 f g = [let y = f () in let z = g () in for x in 1..2..10 -> x + y + z]
let f30 f g = [let y = f () in g (); for x in 1..2..10 -> x + y]
let f31 f g = [f (); g (); for x in 1..2..10 -> x]
let f32 f g = [f (); let y = g () in for x in 1..2..10 -> x + y]

// https://github.com/dotnet/fsharp/issues/19156
let f33 (start : int) (finish : int) f = [for _ in start..finish -> id id ()]
let f34 (start : int64) (finish : int64) f = [for _ in start..finish -> id id ()]
let f35 (start : uint64) (finish : uint64) f = [for _ in start..finish -> id id ()]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,37 @@ type TestItemSeq =
|> compile
|> withErrorCodes [39]
|> ignore

// https://github.com/dotnet/fsharp/issues/19156
[<Fact>]
let ``Generic list comprehension with nested lambda should not cause duplicate entry in type index table``() =
FSharp """
module Test
open System

let f (start: DateTime) (stop: DateTime) (input: (DateTime * 'a) list) =
[
for i in start.Ticks .. stop.Ticks ->
input |> List.where (fun (k, v) -> true)
]
"""
|> compile
|> shouldSucceed
|> ignore

// https://github.com/dotnet/fsharp/issues/19156
[<Fact>]
let ``Generic array comprehension with nested lambda should not cause duplicate entry in type index table``() =
FSharp """
module Test
open System

let f (start: DateTime) (stop: DateTime) (input: (DateTime * 'a) list) =
[|
for i in start.Ticks .. stop.Ticks ->
input |> List.where (fun (k, v) -> true)
|]
"""
|> compile
|> shouldSucceed
|> ignore
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ let ListExpressionSteppingTest8 () =
yield x
]

// Test case from https://github.com/dotnet/fsharp/issues/19156
let ListExpressionSteppingTest9 () =
[
for i in DateTime.Now.Ticks .. DateTime.Now.Ticks + 1L ->
['a', 1] |> List.where (fun (k, v) -> true)
]

let SeqExpressionSteppingTest1 () =
seq { yield 1 }

Expand Down Expand Up @@ -842,6 +849,7 @@ ListExpressionSteppingTest5()
ListExpressionSteppingTest6()
ListExpressionSteppingTest7()
ListExpressionSteppingTest8()
ListExpressionSteppingTest9 () |> ignore
SeqExpressionSteppingTest1()|> Seq.length
SeqExpressionSteppingTest2()|> Seq.length
SeqExpressionSteppingTest3()|> Seq.length
Expand Down
Loading