Skip to content

Commit 1e5b5e4

Browse files
nojafdawedawe
andauthored
Don't consider seq`1 prefix in NicePrint. (#15280)
* Don't consider seq`1 prefix in NicePrint. * Update baselines. * Update full framework baselines. * Moar baselines * Update QuickInfoTests.fs * Update tests * adjust expected output * Set IsPrefixDisplay to false for seq`1. --------- Co-authored-by: dawe <[email protected]>
1 parent 37a5baa commit 1e5b5e4

File tree

27 files changed

+163
-112
lines changed

27 files changed

+163
-112
lines changed

src/Compiler/Driver/CompilerImports.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,9 @@ and [<Sealed>] TcImports
20092009

20102010
let minfo: PickledCcuInfo = data.RawData
20112011
let mspec = minfo.mspec
2012+
2013+
if mspec.DisplayName = "FSharp.Core" then
2014+
updateSeqTypeIsPrefix mspec
20122015

20132016
#if !NO_TYPEPROVIDERS
20142017
let invalidateCcu = Event<_>()

src/Compiler/TypedTree/TypedTreeOps.fs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10607,3 +10607,29 @@ let rec serializeEntity path (entity: Entity) =
1060710607
let json = sw.ToString()
1060810608
use out = FileSystem.OpenFileForWriteShim(path, fileMode = System.IO.FileMode.Create)
1060910609
out.WriteAllText(json)
10610+
10611+
let updateSeqTypeIsPrefix (fsharpCoreMSpec: ModuleOrNamespace) =
10612+
let findModuleOrNamespace (name: string) (entity: Entity) =
10613+
if not entity.IsModuleOrNamespace then
10614+
None
10615+
else
10616+
entity.ModuleOrNamespaceType.ModulesAndNamespacesByDemangledName
10617+
|> Map.tryFind name
10618+
10619+
findModuleOrNamespace "Microsoft" fsharpCoreMSpec
10620+
|> Option.bind (findModuleOrNamespace "FSharp")
10621+
|> Option.bind (findModuleOrNamespace "Collections")
10622+
|> Option.iter (fun collectionsEntity ->
10623+
collectionsEntity.ModuleOrNamespaceType.AllEntitiesByLogicalMangledName
10624+
|> Map.tryFind "seq`1"
10625+
|> Option.iter (fun seqEntity ->
10626+
seqEntity.entity_flags <-
10627+
EntityFlags(
10628+
false,
10629+
seqEntity.entity_flags.IsModuleOrNamespace,
10630+
seqEntity.entity_flags.PreEstablishedHasDefaultConstructor,
10631+
seqEntity.entity_flags.HasSelfReferentialConstructor,
10632+
seqEntity.entity_flags.IsStructRecordOrUnionType
10633+
)
10634+
)
10635+
)

src/Compiler/TypedTree/TypedTreeOps.fsi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,3 +2701,7 @@ val tryAddExtensionAttributeIfNotAlreadyPresent:
27012701

27022702
/// Serialize an entity to a very basic json structure.
27032703
val serializeEntity: path: string -> entity: Entity -> unit
2704+
2705+
/// Updates the IsPrefixDisplay to false for the Microsoft.FSharp.Collections.seq`1 entity
2706+
/// Meant to be called with the FSharp.Core module spec right after it was unpickled.
2707+
val updateSeqTypeIsPrefix: fsharpCoreMSpec: ModuleOrNamespace -> unit

tests/FSharp.Compiler.ComponentTests/CompilerOptions/fsc/flaterrors.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ module flaterrors =
2626
|> compile options
2727
|> shouldFail
2828
|> withDiagnostics [
29-
(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>' ")
30-
(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>' ")
29+
(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' ")
30+
(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' ")
3131
(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'.")
3232
]
3333

@@ -40,8 +40,8 @@ module flaterrors =
4040
|> compile options
4141
|> shouldFail
4242
|> withDiagnostics [
43-
(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>'")
44-
(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>'")
43+
(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'")
44+
(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'")
4545
]
4646

4747
[<InlineData("--flaterrors")>] //once

tests/FSharp.Compiler.ComponentTests/ConstraintSolver/neg_invalid_constructor.fs.err.bsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ neg_invalid_constructor.fs (7,30)-(7,60) typecheck error A unique overload for m
1717
Known type of argument: 'a list
1818

1919
Candidates:
20-
- new: col: 'b -> ImmutableStack<'a> when 'b :> seq<'c>
20+
- new: col: 'b -> ImmutableStack<'a> when 'b :> 'c seq
2121
- private new: items: 'a list -> ImmutableStack<'a>
2222
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.

tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@
246246
<Compile Include="Signatures\ModuleOrNamespaceTests.fs" />
247247
<Compile Include="Signatures\RecordTests.fs" />
248248
<Compile Include="Signatures\ArrayTests.fs" />
249+
<Compile Include="Signatures\SeqTests.fs" />
249250
<Compile Include="Signatures\TypeTests.fs" />
250251
<Compile Include="Signatures\SigGenerationRoundTripTests.fs" />
251252
<Compile Include="Signatures\NestedTypeTests.fs" />
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module FSharp.Compiler.ComponentTests.Signatures.SeqTests
2+
3+
open Xunit
4+
open FSharp.Compiler.ComponentTests.Signatures.TestHelpers
5+
6+
[<Fact>]
7+
let ``int seq`` () =
8+
assertSingleSignatureBinding
9+
"let s = seq { yield 1 }"
10+
"val s: int seq"
11+
12+
[<Fact>]
13+
let ``tuple seq`` () =
14+
assertSingleSignatureBinding
15+
"let s = seq { yield (1, 'b', 2.) }"
16+
"val s: (int * char * float) seq"

tests/fsharp/core/auto-widen/5.0/test.bsl

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -664,62 +664,62 @@ but here has type
664664
'int'
665665

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

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

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

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

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

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

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

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

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

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

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

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

@@ -779,72 +779,72 @@ but here has type
779779
'int'
780780

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -855,5 +855,6 @@ but here has type
855855

856856
test.fsx(454,46,454,47): typecheck error FS0001: This expression was expected to have type
857857
'int64'
858+
'int64'
858859
but here has type
859860
'int'

0 commit comments

Comments
 (0)