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: 3 additions & 0 deletions src/Compiler/Driver/CompilerImports.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,9 @@ and [<Sealed>] TcImports

let minfo: PickledCcuInfo = data.RawData
let mspec = minfo.mspec

if mspec.DisplayName = "FSharp.Core" then
updateSeqTypeIsPrefix mspec

#if !NO_TYPEPROVIDERS
let invalidateCcu = Event<_>()
Expand Down
26 changes: 26 additions & 0 deletions src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10607,3 +10607,29 @@ let rec serializeEntity path (entity: Entity) =
let json = sw.ToString()
use out = FileSystem.OpenFileForWriteShim(path, fileMode = System.IO.FileMode.Create)
out.WriteAllText(json)

let updateSeqTypeIsPrefix (fsharpCoreMSpec: ModuleOrNamespace) =
let findModuleOrNamespace (name: string) (entity: Entity) =
if not entity.IsModuleOrNamespace then
None
else
entity.ModuleOrNamespaceType.ModulesAndNamespacesByDemangledName
|> Map.tryFind name

findModuleOrNamespace "Microsoft" fsharpCoreMSpec
|> Option.bind (findModuleOrNamespace "FSharp")
|> Option.bind (findModuleOrNamespace "Collections")
|> Option.iter (fun collectionsEntity ->
collectionsEntity.ModuleOrNamespaceType.AllEntitiesByLogicalMangledName
|> Map.tryFind "seq`1"
|> Option.iter (fun seqEntity ->
seqEntity.entity_flags <-
EntityFlags(
false,
seqEntity.entity_flags.IsModuleOrNamespace,
seqEntity.entity_flags.PreEstablishedHasDefaultConstructor,
seqEntity.entity_flags.HasSelfReferentialConstructor,
seqEntity.entity_flags.IsStructRecordOrUnionType
)
)
)
4 changes: 4 additions & 0 deletions src/Compiler/TypedTree/TypedTreeOps.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2701,3 +2701,7 @@ val tryAddExtensionAttributeIfNotAlreadyPresent:

/// Serialize an entity to a very basic json structure.
val serializeEntity: path: string -> entity: Entity -> unit

/// Updates the IsPrefixDisplay to false for the Microsoft.FSharp.Collections.seq`1 entity
/// Meant to be called with the FSharp.Core module spec right after it was unpickled.
val updateSeqTypeIsPrefix: fsharpCoreMSpec: ModuleOrNamespace -> unit
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ module flaterrors =
|> compile options
|> shouldFail
|> withDiagnostics [
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\n ''a list' \nbut here has type\n 'seq<'b>' ")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\n ''a list' \nbut here has type\n 'seq<int>' ")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\n ''a list' \nbut here has type\n ''b seq' ")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\n ''a list' \nbut here has type\n 'int seq' ")
(Warning 20, Line 1, Col 1, Line 1, Col 17, "The result of this expression has type ''a list' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.")
]

Expand All @@ -40,8 +40,8 @@ module flaterrors =
|> compile options
|> shouldFail
|> withDiagnostics [
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\029 ''a list' \029but here has type\029 'seq<'b>'")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\029 ''a list' \029but here has type\029 'seq<int>'")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\029 ''a list' \029but here has type\029 ''b seq'")
(Error 1, Line 1, Col 11, Line 1, Col 16, "This expression was expected to have type\029 ''a list' \029but here has type\029 'int seq'")
]

[<InlineData("--flaterrors")>] //once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ neg_invalid_constructor.fs (7,30)-(7,60) typecheck error A unique overload for m
Known type of argument: 'a list

Candidates:
- new: col: 'b -> ImmutableStack<'a> when 'b :> seq<'c>
- new: col: 'b -> ImmutableStack<'a> when 'b :> 'c seq
- private new: items: 'a list -> ImmutableStack<'a>
neg_invalid_constructor.fs (7,30)-(7,60) typecheck error This is not a valid object construction expression. Explicit object constructors must either call an alternate constructor or initialize all fields of the object and specify a call to a super class constructor.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
<Compile Include="Signatures\ModuleOrNamespaceTests.fs" />
<Compile Include="Signatures\RecordTests.fs" />
<Compile Include="Signatures\ArrayTests.fs" />
<Compile Include="Signatures\SeqTests.fs" />
<Compile Include="Signatures\TypeTests.fs" />
<Compile Include="Signatures\SigGenerationRoundTripTests.fs" />
<Compile Include="Signatures\NestedTypeTests.fs" />
Expand Down
16 changes: 16 additions & 0 deletions tests/FSharp.Compiler.ComponentTests/Signatures/SeqTests.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module FSharp.Compiler.ComponentTests.Signatures.SeqTests

open Xunit
open FSharp.Compiler.ComponentTests.Signatures.TestHelpers

[<Fact>]
let ``int seq`` () =
assertSingleSignatureBinding
"let s = seq { yield 1 }"
"val s: int seq"

[<Fact>]
let ``tuple seq`` () =
assertSingleSignatureBinding
"let s = seq { yield (1, 'b', 2.) }"
"val s: (int * char * float) seq"
53 changes: 27 additions & 26 deletions tests/fsharp/core/auto-widen/5.0/test.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -664,62 +664,62 @@ but here has type
'int'

test.fsx(335,28,335,39): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(337,9,338,34): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(340,9,341,33): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(343,9,344,35): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(346,9,347,36): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(349,9,349,36): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(351,9,351,40): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(353,9,354,40): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(356,9,357,41): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(359,9,359,35): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(361,9,362,36): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

test.fsx(364,9,365,37): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a list'

Expand Down Expand Up @@ -779,72 +779,72 @@ but here has type
'int'

test.fsx(390,28,390,41): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(391,30,392,57): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(393,30,394,56): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(395,30,396,58): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(397,30,398,59): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(399,30,399,59): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(400,30,400,63): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(401,30,402,63): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(403,30,404,64): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(405,31,405,59): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(406,31,407,60): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(408,31,409,61): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
''a array'

test.fsx(429,10,437,16): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
'OtherSeq<'a>'

test.fsx(448,9,450,49): typecheck error FS0001: This expression was expected to have type
'seq<int64>'
'int64 seq'
but here has type
'OtherSeqImpl<'a>'

Expand All @@ -855,5 +855,6 @@ but here has type

test.fsx(454,46,454,47): typecheck error FS0001: This expression was expected to have type
'int64'
'int64'
but here has type
'int'
Loading