Skip to content

Commit cbb34c1

Browse files
committed
Fixed merge issues
1 parent 4a9a221 commit cbb34c1

37 files changed

+592
-306
lines changed

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: A non-nullable '{0}' was expected but this expression is nullable. Consider either changing the target to also be nullable, or use pattern matching to safely handle the null case of this expression."
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 =
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//------------------------------------------------------------------------
2+
// shims for things not yet implemented in Fable
3+
//------------------------------------------------------------------------
4+
5+
namespace System.Collections.Concurrent
6+
7+
open System.Collections.Generic
8+
9+
// not thread safe, just a ResizeArray // TODO: threaded implementation
10+
type ConcurrentStack<'T>() =
11+
let xs = ResizeArray<'T>()
12+
13+
member _.Push (item: 'T) = xs.Add(item)
14+
member _.PushRange (items: 'T[]) = xs.AddRange(items)
15+
member _.Clear () = xs.Clear()
16+
member _.ToArray () = xs.ToArray()
17+
18+
interface IEnumerable<'T> with
19+
member _.GetEnumerator() =
20+
xs.GetEnumerator()
21+
22+
interface System.Collections.IEnumerable with
23+
member _.GetEnumerator() =
24+
(xs.GetEnumerator() :> System.Collections.IEnumerator)
25+
26+
// not thread safe, just a Dictionary // TODO: threaded implementation
27+
[<AllowNullLiteral>]
28+
type ConcurrentDictionary<'K, 'V>(comparer: IEqualityComparer<'K>) =
29+
inherit Dictionary<'K, 'V>(comparer)
30+
31+
new () =
32+
ConcurrentDictionary<'K, 'V>(EqualityComparer.Default)
33+
new (_concurrencyLevel: int, _capacity: int) =
34+
ConcurrentDictionary<'K, 'V>()
35+
new (_concurrencyLevel: int, comparer: IEqualityComparer<'K>) =
36+
ConcurrentDictionary<'K, 'V>(comparer)
37+
new (_concurrencyLevel: int, _capacity: int, comparer: IEqualityComparer<'K>) =
38+
ConcurrentDictionary<'K, 'V>(comparer)
39+
40+
member x.TryAdd (key: 'K, value: 'V): bool =
41+
if x.ContainsKey(key)
42+
then false
43+
else x.Add(key, value); true
44+
45+
member x.TryRemove (key: 'K): bool * 'V =
46+
match x.TryGetValue(key) with
47+
| true, v -> (x.Remove(key), v)
48+
| _ as res -> res
49+
50+
member x.GetOrAdd (key: 'K, value: 'V): 'V =
51+
match x.TryGetValue(key) with
52+
| true, v -> v
53+
| _ -> let v = value in x.Add(key, v); v
54+
55+
member x.GetOrAdd (key: 'K, valueFactory: System.Func<'K, 'V>): 'V =
56+
match x.TryGetValue(key) with
57+
| true, v -> v
58+
| _ -> let v = valueFactory.Invoke(key) in x.Add(key, v); v
59+
60+
// member x.GetOrAdd<'Arg> (key: 'K, valueFactory: 'K * 'Arg -> 'V, arg: 'Arg): 'V =
61+
// match x.TryGetValue(key) with
62+
// | true, v -> v
63+
// | _ -> let v = valueFactory(key, arg) in x.Add(key, v); v
64+
65+
member x.TryUpdate (key: 'K, value: 'V, comparisonValue: 'V): bool =
66+
match x.TryGetValue(key) with
67+
| true, v when Unchecked.equals v comparisonValue -> x[key] <- value; true
68+
| _ -> false
69+
70+
member x.AddOrUpdate (key: 'K, value: 'V, updateFactory: System.Func<'K, 'V, 'V>): 'V =
71+
match x.TryGetValue(key) with
72+
| true, v -> let v = updateFactory.Invoke(key, v) in x[key] <- v; v
73+
| _ -> let v = value in x.Add(key, v); v
74+
75+
// member x.AddOrUpdate (key: 'K, valueFactory: 'K -> 'V, updateFactory: 'K * 'V -> 'V): 'V =
76+
// match x.TryGetValue(key) with
77+
// | true, v -> let v = updateFactory(key, v) in x[key] <- v; v
78+
// | _ -> let v = valueFactory(key) in x.Add(key, v); v
79+
80+
// member x.AddOrUpdate (key: 'K, valueFactory: 'K * 'Arg -> 'V, updateFactory: 'K * 'Arg * 'V -> 'V, arg: 'Arg): 'V =
81+
// match x.TryGetValue(key) with
82+
// | true, v -> let v = updateFactory(key, arg, v) in x[key] <- v; v
83+
// | _ -> let v = valueFactory(key, arg) in x.Add(key, v); v
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//------------------------------------------------------------------------
2+
// shims for things not yet implemented in Fable
3+
//------------------------------------------------------------------------
4+
5+
namespace System.Collections.Generic
6+
7+
[<AllowNullLiteral>]
8+
type LinkedListNode<'T>(value: 'T) =
9+
member val Value = value with get, set
10+
member val Previous: LinkedListNode<'T> = null with get, set
11+
member val Next: LinkedListNode<'T> = null with get, set
12+
13+
type LinkedList<'T>() =
14+
let mutable head: LinkedListNode<'T> = null
15+
let mutable tail: LinkedListNode<'T> = null
16+
17+
// Get the first node in the list
18+
member _.First = head
19+
20+
// Get the last node in the list
21+
member _.Last = tail
22+
23+
// Get the number of nodes in the list
24+
member _.Count =
25+
let rec loop (currentNode: LinkedListNode<'T>) count =
26+
if currentNode = null then count
27+
else loop currentNode.Next (count + 1)
28+
loop head 0
29+
30+
// Clear the list
31+
member _.Clear() =
32+
head <- null
33+
tail <- null
34+
35+
// Add a new node to the end of the list
36+
member _.AddLast(value: 'T) =
37+
let newNode = LinkedListNode(value)
38+
if tail = null then
39+
head <- newNode
40+
tail <- newNode
41+
else
42+
tail.Next <- newNode
43+
newNode.Previous <- tail
44+
tail <- newNode
45+
newNode
46+
47+
// Add a node to the end of the list
48+
member _.AddLast(node: LinkedListNode<'T>) =
49+
if tail = null then
50+
node.Next <- null
51+
node.Previous <- null
52+
head <- node
53+
tail <- node
54+
else
55+
tail.Next <- node
56+
node.Next <- null
57+
node.Previous <- tail
58+
tail <- node
59+
60+
// Add a new node to the beginning of the list
61+
member _.AddFirst(value: 'T) =
62+
let newNode = LinkedListNode(value)
63+
if head = null then
64+
head <- newNode
65+
tail <- newNode
66+
else
67+
head.Previous <- newNode
68+
newNode.Next <- head
69+
head <- newNode
70+
newNode
71+
72+
// Add a node to the beginning of the list
73+
member _.AddFirst(node: LinkedListNode<'T>) =
74+
if head = null then
75+
node.Next <- null
76+
node.Previous <- null
77+
head <- node
78+
tail <- node
79+
else
80+
head.Previous <- node
81+
node.Next <- head
82+
node.Previous <- null
83+
head <- node
84+
85+
// Remove a node from the list
86+
member _.Remove(node: LinkedListNode<'T>) =
87+
match node.Previous, node.Next with
88+
| null, null ->
89+
head <- null
90+
tail <- null
91+
| null, nextNode ->
92+
nextNode.Previous <- null
93+
head <- nextNode
94+
| prevNode, null ->
95+
prevNode.Next <- null
96+
tail <- prevNode
97+
| prevNode, nextNode ->
98+
prevNode.Next <- nextNode
99+
nextNode.Previous <- prevNode
100+
101+
// Find a node by value
102+
member _.Find(value: 'T) =
103+
let rec loop (currentNode: LinkedListNode<'T>) =
104+
if currentNode = null then null
105+
elif Unchecked.equals currentNode.Value value then currentNode
106+
else loop currentNode.Next
107+
loop head
108+
109+
// Implement IEnumerable interface
110+
interface System.Collections.Generic.IEnumerable<'T> with
111+
member _.GetEnumerator() =
112+
let rec loop (currentNode: LinkedListNode<'T>) =
113+
seq {
114+
if currentNode <> null then
115+
yield currentNode.Value
116+
yield! loop currentNode.Next
117+
}
118+
(loop head).GetEnumerator()
119+
120+
member this.GetEnumerator() : System.Collections.IEnumerator =
121+
(this :> System.Collections.Generic.IEnumerable<'T>).GetEnumerator() :> System.Collections.IEnumerator

0 commit comments

Comments
 (0)