Skip to content

Commit 728476e

Browse files
committed
Fixed merge issues
1 parent 932b994 commit 728476e

24 files changed

Lines changed: 258 additions & 90 deletions

buildtools/buildtools.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
BeforeTargets="CoreCompile">
2121

2222
<PropertyGroup>
23-
<FsLexPath Condition="'$(FsLexPath)' == ''">$(ArtifactsDir)\bin\fslex\Release\net8.0\fslex.dll</FsLexPath>
23+
<FsLexPath Condition="'$(FsLexPath)' == ''">$(ArtifactsDir)\bin\fslex\Release\net9.0\linux-x64\fslex.dll</FsLexPath>
2424
</PropertyGroup>
2525

2626
<!-- Create the output directory -->
@@ -44,7 +44,7 @@
4444
BeforeTargets="CoreCompile">
4545

4646
<PropertyGroup>
47-
<FsYaccPath Condition="'$(FsYaccPath)' == ''">$(ArtifactsDir)\bin\fsyacc\Release\net8.0\fsyacc.dll</FsYaccPath>
47+
<FsYaccPath Condition="'$(FsYaccPath)' == ''">$(ArtifactsDir)\bin\fsyacc\Release\net9.0\linux-x64\fsyacc.dll</FsYaccPath>
4848
</PropertyGroup>
4949

5050
<!-- Create the output directory -->

fcs/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
cd $(dirname $0)/..
55

66
# build fslex/fsyacc tools
7-
dotnet build -c Release buildtools
7+
dotnet build -c Release buildtools/fslex
8+
dotnet build -c Release buildtools/fsyacc
9+
810
# build FSharp.Compiler.Service (to make sure it's not broken)
911
dotnet build -c Release src/Compiler
1012

fcs/fcs-fable/FSStrings.fs

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ let resources =
1414
( "ConstraintSolverMissingConstraint",
1515
"A type parameter is missing a constraint '{0}'"
1616
);
17+
( "ConstraintSolverNullnessWarningEquivWithTypes",
18+
"Nullness warning: The types '{0}' and '{1}' do not have equivalent nullability."
19+
);
20+
( "ConstraintSolverNullnessWarningWithTypes",
21+
"Nullness warning: The types '{0}' and '{1}' do not have compatible nullability."
22+
);
23+
( "ConstraintSolverNullnessWarningWithType",
24+
"Nullness warning: The type '{0}' does not support 'null'."
25+
);
26+
( "ConstraintSolverNullnessWarning",
27+
"Nullness warning: {0}."
28+
);
1729
( "ConstraintSolverTypesNotInEqualityRelation1",
1830
"The unit of measure '{0}' does not match the unit of measure '{1}'"
1931
);
@@ -69,7 +81,7 @@ let resources =
6981
"Duplicate definition of {0} '{1}'"
7082
);
7183
( "NameClash2",
72-
"The {0} '{1}' can not be defined because the name '{2}' clashes with the {3} '{4}' in this type or module"
84+
"The {0} '{1}' cannot be defined because the name '{2}' clashes with the {3} '{4}' in this type or module"
7385
);
7486
( "Duplicate1",
7587
"Two members called '{0}' have the same signature"
@@ -105,7 +117,7 @@ let resources =
105117
"A coercion from the value type \n {0} \nto the type \n {1} \nwill involve boxing. Consider using 'box' instead"
106118
);
107119
( "TypeIsImplicitlyAbstract",
108-
"This type is 'abstract' since some abstract members have not been given an implementation. If this is intentional then add the '[<AbstractClass>]' attribute to your type."
120+
"Non-abstract classes cannot contain abstract members. Either provide a default member implementation or add the '[<AbstractClass>]' attribute to your type."
109121
);
110122
( "NonRigidTypar1",
111123
"This construct causes code to be less generic than indicated by its type annotations. The type variable implied by the use of a '#', '_' or other type annotation at or near '{0}' has been constrained to be type '{1}'."
@@ -299,6 +311,9 @@ let resources =
299311
( "Parser.TOKEN.BAR.RBRACE",
300312
"symbol '|}'"
301313
);
314+
( "Parser.TOKEN.BAR_JUST_BEFORE_NULL",
315+
"symbol '|' (directly before 'null')"
316+
);
302317
( "Parser.TOKEN.GREATER.RBRACE",
303318
"symbol '>}'"
304319
);
@@ -914,20 +929,11 @@ let resources =
914929
( "MissingFields",
915930
"The following fields require values: {0}"
916931
);
917-
( "ValueRestriction1",
918-
"Value restriction. The value '{0}' has generic type\n {1} \nEither make the arguments to '{2}' explicit or, if you do not intend for it to be generic, add a type annotation."
932+
( "ValueRestrictionFunction",
933+
"""Value restriction: The value '{0}' has an inferred generic function type\n {1}\nHowever, values cannot have generic type variables like '_a in "let f: '_a". You should define '{2}' as a function instead by doing one of the following:\n- Add an explicit parameter that is applied instead of using a partial application "let f param"\n- Add a unit parameter like "let f()"\n- Write explicit type parameters like "let f<'a>"\nor if you do not intend for it to be generic, either:\n- Add an explicit type annotation like "let f : obj -> obj"\n- Apply arguments of non-generic types to the function value in later code for type inference like "do f()".\nThis error is because a let binding without parameters defines a value, not a function. Values cannot be generic because reading a value is assumed to result in the same everywhere but generic type parameters may invalidate this assumption by enabling type-dependent results."""
919934
);
920-
( "ValueRestriction2",
921-
"Value restriction. The value '{0}' has generic type\n {1} \nEither make '{2}' into a function with explicit arguments or, if you do not intend for it to be generic, add a type annotation."
922-
);
923-
( "ValueRestriction3",
924-
"Value restriction. This member has been inferred to have generic type\n {0} \nConstructors and property getters/setters cannot be more generic than the enclosing type. Add a type annotation to indicate the exact types involved."
925-
);
926-
( "ValueRestriction4",
927-
"Value restriction. The value '{0}' has been inferred to have generic type\n {1} \nEither make the arguments to '{2}' explicit or, if you do not intend for it to be generic, add a type annotation."
928-
);
929-
( "ValueRestriction5",
930-
"Value restriction. The value '{0}' has been inferred to have generic type\n {1} \nEither define '{2}' as a simple data term, make it a function with explicit arguments or, if you do not intend for it to be generic, add a type annotation."
935+
( "ValueRestriction",
936+
"""Value restriction: The value '{0}' has an inferred generic type\n {1}\nHowever, values cannot have generic type variables like '_a in "let x: '_a". You can do one of the following:\n- Define it as a simple data term like an integer literal, a string literal or a union case like "let x = 1"\n- Add an explicit type annotation like "let x : int"\n- Use the value as a non-generic type in later code for type inference like "do x"\nor if you still want type-dependent results, you can define '{2}' as a function instead by doing either:\n- Add a unit parameter like "let x()"\n- Write explicit type parameters like "let x<'a>".\nThis error is because a let binding without parameters defines a value, not a function. Values cannot be generic because reading a value is assumed to result in the same everywhere but generic type parameters may invalidate this assumption by enabling type-dependent results."""
931937
);
932938
( "RecoverableParseError",
933939
"syntax error"
@@ -945,7 +951,7 @@ let resources =
945951
"Override implementations should be given as part of the initial declaration of a type."
946952
);
947953
( "IntfImplInIntrinsicAugmentation",
948-
"Interface implementations should normally be given on the initial declaration of a type. Interface implementations in augmentations may lead to accessing static bindings before they are initialized, though only if the interface implementation is invoked during initialization of the static data, and in turn access the static data. You may remove this warning using #nowarn \"69\" if you have checked this is not the case."
954+
"Interface implementations should normally be given on the initial declaration of a type. Interface implementations in augmentations may lead to accessing static bindings before they are initialized, though only if the interface implementation is invoked during initialization of the static data, and in turn access the static data. You may remove this warning using '#nowarn \"69\"' if you have checked this is not the case."
949955
);
950956
( "IntfImplInExtrinsicAugmentation",
951957
"Interface implementations should be given on the initial declaration of a type."
@@ -957,10 +963,10 @@ let resources =
957963
"The type referenced through '{0}' is defined in an assembly that is not referenced. You must add a reference to assembly '{1}'."
958964
);
959965
( "HashIncludeNotAllowedInNonScript",
960-
"#I directives may only occur in F# script files (extensions .fsx or .fsscript). Either move this code to a script file, add a '-I' compiler option for this reference or delimit the directive with delimit it with '#if INTERACTIVE'/'#endif'."
966+
"#I directives may only be used in F# script files (extensions .fsx or .fsscript). Either move this code to a script file, add a '-I' compiler option for this reference or delimit the directive with delimit it with '#if INTERACTIVE'/'#endif'."
961967
);
962968
( "HashReferenceNotAllowedInNonScript",
963-
"#r directives may only occur in F# script files (extensions .fsx or .fsscript). Either move this code to a script file or replace this reference with the '-r' compiler option. If this directive is being executed as user input, you may delimit it with '#if INTERACTIVE'/'#endif'."
969+
"#r directives may only be used in F# script files (extensions .fsx or .fsscript). Either move this code to a script file or replace this reference with the '-r' compiler option. If this directive is being executed as user input, you may delimit it with '#if INTERACTIVE'/'#endif'."
964970
);
965971
( "HashDirectiveNotAllowedInNonScript",
966972
"This directive may only be used in F# script files (extensions .fsx or .fsscript). Either remove the directive, move this code to a script file or delimit the directive with '#if INTERACTIVE'/'#endif'."
@@ -1007,6 +1013,9 @@ let resources =
10071013
( "ArgumentsInSigAndImplMismatch",
10081014
"The argument names in the signature '{0}' and implementation '{1}' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling."
10091015
);
1016+
( "DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer",
1017+
"The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3}"
1018+
);
10101019
( "Parser.TOKEN.WHILE.BANG",
10111020
"keyword 'while!'"
10121021
);

fcs/fcs-fable/SR.fs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
namespace FSharp.Compiler
66

77
module SR =
8-
let GetString(name: string) =
8+
let GetString (name: string) =
99
match SR.Resources.resources.TryGetValue(name) with
1010
| true, value -> value
1111
| _ -> "Missing FSStrings error message for: " + name
1212

13+
module FSComp =
14+
module SR =
15+
let GetTextOpt (name: string) =
16+
match SR.Resources.resources.TryGetValue(name) with
17+
| true, value -> Some value
18+
| _ -> None
19+
1320
module DiagnosticMessage =
1421
type ResourceString<'T>(sfmt: string, fmt: string) =
1522
member x.Format =

fcs/fcs-fable/System.Collections.fs

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ namespace System.Collections
77
module Immutable =
88
open System.Collections.Generic
99

10-
// not immutable, just a ResizeArray // TODO: immutable implementation
11-
type ImmutableArray<'T> =
12-
static member CreateBuilder() = ResizeArray<'T>()
10+
// not immutable, just an Array // TODO: immutable implementation
11+
type ImmutableArray<'T> = 'T array
12+
13+
module ImmutableArray =
14+
let CreateBuilder<'T>() = ResizeArray<'T>()
15+
let Create<'T>(items: 'T[], start: int, length: int) =
16+
items[start..(start + length - 1)]
1317

1418
[<Sealed>]
1519
type ImmutableHashSet<'T when 'T: equality>(values: 'T seq) =
1620
let xs = HashSet<'T>(values)
1721

18-
static member Create<'T>(values) = ImmutableHashSet<'T>(values)
22+
static member Create<'T>(values: 'T seq) = ImmutableHashSet<'T>(values)
1923
static member Empty = ImmutableHashSet<'T>(Array.empty)
2024

2125
member _.Add (value: 'T) =
@@ -187,3 +191,36 @@ module Concurrent =
187191
interface System.Collections.IEnumerable with
188192
member _.GetEnumerator() =
189193
(xs.GetEnumerator() :> System.Collections.IEnumerator)
194+
195+
interface ICollection<KeyValuePair<'K, 'V>> with
196+
member _.Add(item: KeyValuePair<'K, 'V>) : unit =
197+
(xs :> ICollection<_>).Add(item)
198+
199+
member _.Clear() : unit = (xs :> ICollection<_>).Clear()
200+
201+
member _.Contains(item: KeyValuePair<'K, 'V>) : bool =
202+
(xs :> ICollection<_>).Contains(item)
203+
204+
member _.CopyTo(array: KeyValuePair<'K, 'V>[], arrayIndex: int) : unit =
205+
(xs :> ICollection<_>).CopyTo(array, arrayIndex)
206+
207+
member _.Count: int = (xs :> ICollection<_>).Count
208+
member _.IsReadOnly: bool = (xs :> ICollection<_>).IsReadOnly
209+
210+
member _.Remove(item: KeyValuePair<'K, 'V>) : bool =
211+
(xs :> ICollection<_>).Remove(item)
212+
213+
interface IDictionary<'K, 'V> with
214+
member _.Add(key: 'K, value: 'V) = xs.Add(key, value)
215+
member _.ContainsKey(key: 'K) = xs.ContainsKey(key)
216+
217+
member _.Item
218+
with get (key: 'K): 'V = xs.[key]
219+
and set (key: 'K) (v: 'V): unit = xs.[key] <- v
220+
221+
member _.TryGetValue(key: 'K, value: byref<'V>) =
222+
xs.TryGetValue(key, &value)
223+
224+
member _.Remove(key: 'K) = xs.Remove(key)
225+
member _.Keys = xs.Keys
226+
member _.Values = xs.Values

fcs/fcs-fable/TcImports_shim.fs

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,14 @@ module TcImports =
4545
let tcImports = TcImports ()
4646

4747
let sigDataReaders ilModule =
48-
[ for resource in ilModule.Resources.AsList() do
49-
if IsSignatureDataResource resource then
50-
let _ccuName, getBytes = GetResourceNameAndSignatureDataFunc resource
51-
getBytes() ]
48+
ilModule.Resources.AsList()
49+
|> GetResourceNameAndSignatureDataFuncs
50+
|> List.map snd
5251

5352
let optDataReaders ilModule =
54-
[ for resource in ilModule.Resources.AsList() do
55-
if IsOptimizationDataResource resource then
56-
let _ccuName, getBytes = GetResourceNameAndOptimizationDataFunc resource
57-
getBytes() ]
53+
ilModule.Resources.AsList()
54+
|> GetResourceNameAndOptimizationDataFuncs
55+
|> List.map snd
5856

5957
let LoadMod (ccuName: string) =
6058
let fileName =
@@ -71,11 +69,25 @@ module TcImports =
7169
let reader = ILBinaryReader.OpenILModuleReaderFromBytes fileName bytes opts
7270
reader.ILModuleDef //, reader.ILAssemblyRefs
7371

74-
let GetSignatureData (fileName:string, ilScopeRef, ilModule:ILModuleDef option, bytes: ReadOnlyByteMemory) =
75-
unpickleObjWithDanglingCcus fileName ilScopeRef ilModule unpickleCcuInfo bytes
72+
let GetSignatureData (file, ilScopeRef, ilModule, byteReaderA, byteReaderB) : PickledDataWithReferences<PickledCcuInfo> =
73+
let memA = byteReaderA ()
7674

77-
let GetOptimizationData (fileName:string, ilScopeRef, ilModule:ILModuleDef option, bytes: ReadOnlyByteMemory) =
78-
unpickleObjWithDanglingCcus fileName ilScopeRef ilModule Optimizer.u_CcuOptimizationInfo bytes
75+
let memB =
76+
(match byteReaderB with
77+
| None -> ByteMemory.Empty.AsReadOnly()
78+
| Some br -> br ())
79+
80+
unpickleObjWithDanglingCcus file ilScopeRef ilModule unpickleCcuInfo memA memB
81+
82+
let GetOptimizationData (file:string, ilScopeRef, ilModule, byteReaderA, byteReaderB) =
83+
let memA = byteReaderA ()
84+
85+
let memB =
86+
(match byteReaderB with
87+
| None -> ByteMemory.Empty.AsReadOnly()
88+
| Some br -> br ())
89+
90+
unpickleObjWithDanglingCcus file ilScopeRef ilModule Optimizer.u_CcuOptimizationInfo memA memB
7991

8092
let memoize_mod = new MemoizationTable<_,_> (LoadMod, keyComparer=HashIdentity.Structural)
8193

@@ -86,7 +98,7 @@ module TcImports =
8698
let fileName = ilModule.Name //TODO: try with ".sigdata" extension
8799
match sigDataReaders ilModule with
88100
| [] -> None
89-
| bytes::_ -> Some (GetSignatureData (fileName, ilScopeRef, Some ilModule, bytes))
101+
| (readerA, readerB)::_ -> Some (GetSignatureData (fileName, ilScopeRef, Some ilModule, readerA, readerB))
90102

91103
let LoadOptData ccuName =
92104
let ilModule = memoize_mod.Apply ccuName
@@ -95,7 +107,7 @@ module TcImports =
95107
let fileName = ilModule.Name //TODO: try with ".optdata" extension
96108
match optDataReaders ilModule with
97109
| [] -> None
98-
| bytes::_ -> Some (GetOptimizationData (fileName, ilScopeRef, Some ilModule, bytes))
110+
| (readerA, readerB)::_ -> Some (GetOptimizationData (fileName, ilScopeRef, Some ilModule, readerA, readerB))
99111

100112
let memoize_sig = new MemoizationTable<_,_> (LoadSigData, keyComparer=HashIdentity.Structural)
101113
let memoize_opt = new MemoizationTable<_,_> (LoadOptData, keyComparer=HashIdentity.Structural)
@@ -250,6 +262,7 @@ module TcImports =
250262
#endif
251263
None
252264

265+
let fslibCcu = fslibCcuInfo.FSharpViewOfMetadata
253266
let primaryScopeRef = primaryCcuInfo.ILScopeRef
254267
let fsharpCoreScopeRef = fslibCcuInfo.ILScopeRef
255268
let assembliesThatForwardToPrimaryAssembly = []
@@ -259,16 +272,19 @@ module TcImports =
259272
TcGlobals(
260273
tcConfig.compilingFSharpCore,
261274
ilGlobals,
262-
fslibCcuInfo.FSharpViewOfMetadata,
275+
fslibCcu,
263276
tcConfig.implicitIncludeDir,
264277
tcConfig.mlCompatibility,
265278
tcConfig.isInteractive,
279+
tcConfig.checkNullness,
266280
tcConfig.useReflectionFreeCodeGen,
267281
tryFindSysTypeCcu,
268282
tcConfig.emitDebugInfoInQuotations,
269283
tcConfig.noDebugAttributes,
270284
tcConfig.pathMap,
271-
tcConfig.langVersion
285+
tcConfig.langVersion,
286+
tcConfig.realsig,
287+
tcConfig.compilationMode
272288
)
273289

274290
#if DEBUG

fcs/fcs-fable/codegen/codegen.fsproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!-- <Import Project="fssrgen.targets" /> -->
88
<PropertyGroup>
99
<OutputType>Exe</OutputType>
10-
<TargetFramework>net8.0</TargetFramework>
10+
<TargetFramework>net9.0</TargetFramework>
1111
<!-- <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference> -->
1212
</PropertyGroup>
1313
<ItemGroup>
@@ -30,11 +30,11 @@
3030
<Link>SyntaxTree/pplex.fsl</Link>
3131
</FsLex>
3232
<FsYacc Include="$(FSharpSourcesRoot)/pppars.fsy">
33-
<OtherFlags>--module FSharp.Compiler.PPParser --open FSharp.Compiler.ParseHelpers --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing --buffer-type-argument char</OtherFlags>
33+
<OtherFlags>--module FSharp.Compiler.PPParser --open FSharp.Compiler.ParseHelpers --open FSharp.Compiler.LexerStore --internal --lexlib Internal.Utilities.Text.Lexing --parslib Internal.Utilities.Text.Parsing --buffer-type-argument char</OtherFlags>
3434
<Link>SyntaxTree/pppars.fsy</Link>
3535
</FsYacc>
3636
<FsLex Include="$(FSharpSourcesRoot)/lex.fsl">
37-
<OtherFlags>--module FSharp.Compiler.Lexer --open FSharp.Compiler.Lexhelp --open Internal.Utilities.Text.Lexing --open FSharp.Compiler.Parser --open FSharp.Compiler.Text --open FSharp.Compiler.ParseHelpers --internal --unicode --lexlib Internal.Utilities.Text.Lexing</OtherFlags>
37+
<OtherFlags>--module FSharp.Compiler.Lexer --open FSharp.Compiler.Lexhelp --open Internal.Utilities.Text.Lexing --open FSharp.Compiler.Parser --open FSharp.Compiler.Text --open FSharp.Compiler.ParseHelpers --open FSharp.Compiler.LexerStore --internal --unicode --lexlib Internal.Utilities.Text.Lexing</OtherFlags>
3838
<Link>SyntaxTree/lex.fsl</Link>
3939
</FsLex>
4040
<FsYacc Include="$(FSharpSourcesRoot)/pars.fsy">

0 commit comments

Comments
 (0)