Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Fable-FCS to F# 9 #3960

Merged
merged 4 commits into from
Jan 14, 2025
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
// "type": "coreclr",
// "request": "launch",
// "preLaunchTask": "build bench-compiler",
// "program": "${workspaceRoot}/src/fable-standalone/test/bench-compiler/src/bin/Debug/net8.0/bench-compiler.dll",
// "program": "${workspaceRoot}/src/fable-standalone/test/bench-compiler/bin/Debug/net9.0/bench-compiler.dll",
// "args": ["${workspaceRoot}/../fable-test/fable-test.fsproj", "--outDir", "./out-test", "--fableLib", "./out-lib-js"],
// "cwd": "${workspaceRoot}/src/fable-standalone/test/bench-compiler",
// "stopAtEntry": false,
Expand All @@ -181,7 +181,7 @@
// "type": "lldb",
// "request": "launch",
// "preLaunchTask": "publish bench-compiler",
// "program": "${workspaceRoot}/src/fable-standalone/test/bench-compiler/src/bin/Debug/net8.0/linux-x64/native/bench-compiler",
// "program": "${workspaceRoot}/src/fable-standalone/test/bench-compiler/bin/Debug/net9.0/linux-x64/native/bench-compiler",
// "args": ["${workspaceRoot}/../fable-test/fable-test.fsproj", "--outDir", "./out-test", "--fableLib", "./out-lib-js"],
// "cwd": "${workspaceRoot}/src/fable-standalone/test/bench-compiler",
// "console": "internalConsole"
Expand Down Expand Up @@ -275,7 +275,7 @@
"name": "Bench.Cli on ../fable-test",
"type": "coreclr",
"request": "launch",
"program": "${workspaceRoot}/src/fable-standalone/test/bench-compiler/src/bin/Debug/net8.0/bench-compiler.dll",
"program": "${workspaceRoot}/src/fable-standalone/test/bench-compiler/bin/Debug/net9.0/bench-compiler.dll",
"args": [
"fable-test.fsproj",
"--outDir", "${workspaceRoot}/../fable-test",
Expand Down
39 changes: 33 additions & 6 deletions src/Fable.Transforms/Rust/AST/Rust.AST.Adapters.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,46 @@ type System.Collections.Generic.IList<'T> with
else
Some(self.Item(self.Count - 1))

type System.Collections.Generic.IEnumerable<'T> with
// // These no longer work on .NET 9.0, see https://github.com/dotnet/fsharp/issues/18001

member self.iter() = self.GetEnumerator()
// type System.Collections.Generic.IEnumerable<'T> with

type System.Collections.Generic.IEnumerator<'T> with
// member self.iter() = self.GetEnumerator()

member self.next() =
// type System.Collections.Generic.IEnumerator<'T> with

// member self.next() =
// if self.MoveNext() then
// Some(self.Current)
// else
// None

// member self.enumerate() =
// { new System.Collections.Generic.IEnumerable<'T> with
// member x.GetEnumerator() = self
// interface System.Collections.IEnumerable with
// member x.GetEnumerator() =
// (self :> System.Collections.IEnumerator)
// }

[<System.Runtime.CompilerServices.Extension>]
type IEnumerableExtensions =

[<System.Runtime.CompilerServices.Extension>]
static member inline iter(self: System.Collections.Generic.IEnumerable<'T>) = self.GetEnumerator()

[<System.Runtime.CompilerServices.Extension>]
type IEnumeratorExtensions =

[<System.Runtime.CompilerServices.Extension>]
static member inline next(self: System.Collections.Generic.IEnumerator<'T>) =
if self.MoveNext() then
Some(self.Current)
else
None

member self.enumerate() =
[<System.Runtime.CompilerServices.Extension>]
static member inline enumerate(self: System.Collections.Generic.IEnumerator<'T>) =
{ new System.Collections.Generic.IEnumerable<'T> with
member x.GetEnumerator() = self
interface System.Collections.IEnumerable with
Expand Down Expand Up @@ -235,7 +262,7 @@ type Macros =
static member panic() = failwith "panic!"
static member panic(str: string) = failwith str

static member format(fmt: string, [<System.ParamArray>] args) = System.String.Format(fmt, args)
static member format(fmt: string, [<System.ParamArray>] args: obj array) = System.String.Format(fmt, args)

static member write(buf: String, str: string) = buf.push_str (str)

Expand Down
12 changes: 9 additions & 3 deletions src/fable-compiler-js/src/app.fs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,15 @@ type SourceWriter(sourcePath, targetPath, projDir, options: CmdLineOptions, file
column = srcCol
}

mapGenerator
.Force()
.AddMapping(generated, original, source = sourcePath, ?name = name)
// This is a workaround for:
// https://github.com/fable-compiler/Fable/issues/3980
// We are still investigating why some of the F# code don't have source information
// I believe for now we can ship it like that because it only deteriorate the source map
// it should not break them completely.
if srcLine <> 0 && srcCol <> 0 then
mapGenerator
.Force()
.AddMapping(generated, original, source = sourcePath, ?name = name)

member _.Dispose() = ()

Expand Down
Binary file modified src/fable-metadata/lib/Browser.Blob.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/Browser.Dom.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/Browser.Event.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/Browser.Gamepad.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/Browser.WebGL.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/Browser.WebStorage.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/FSharp.Core.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/Fable.Core.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Collections.Concurrent.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Collections.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.ComponentModel.Primitives.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.ComponentModel.TypeConverter.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.ComponentModel.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Console.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Core.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Diagnostics.Debug.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Diagnostics.Tools.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Diagnostics.Tracing.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Globalization.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.IO.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Net.Requests.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Net.WebClient.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Numerics.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Reflection.Extensions.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Reflection.Metadata.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Reflection.Primitives.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Reflection.TypeExtensions.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Reflection.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Runtime.Extensions.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Runtime.InteropServices.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Runtime.Numerics.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Runtime.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Text.Encoding.Extensions.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Text.Encoding.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Text.RegularExpressions.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Threading.Tasks.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Threading.Thread.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.Threading.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.ValueTuple.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/System.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/mscorlib.dll
Binary file not shown.
Binary file modified src/fable-metadata/lib/netstandard.dll
Binary file not shown.
12 changes: 9 additions & 3 deletions src/fable-standalone/test/bench-compiler/app.fs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,15 @@ type SourceWriter(sourcePath, targetPath, projDir, options: CmdLineOptions, file
column = srcCol
}

mapGenerator
.Force()
.AddMapping(generated, original, source = sourcePath, ?name = name)
// This is a workaround for:
// https://github.com/fable-compiler/Fable/issues/3980
// We are still investigating why some of the F# code don't have source information
// I believe for now we can ship it like that because it only deteriorate the source map
// it should not break them completely.
if srcLine <> 0 && srcCol <> 0 then
mapGenerator
.Force()
.AddMapping(generated, original, source = sourcePath, ?name = name)

member _.Dispose() = ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RollForward>Major</RollForward>
<DefineConstants>$(DefineConstants);DOTNET_FILE_SYSTEM</DefineConstants>
<OtherFlags>$(OtherFlags) --crossoptimize-</OtherFlags>
Expand Down
1 change: 1 addition & 0 deletions src/fable-standalone/test/bench-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"build-tests-opt": "npm run build-tests-js -- --optimize",
"build-tests-node": "npm run fable-node -- ../../../../tests/Js/Main/Fable.Tests.fsproj --outDir ./out-tests --fableLib ./out-lib-js --sourceMaps",
"postbuild-tests-js": "npm run mocha -- out-tests --colors --reporter dot -t 10000",
"postbuild-tests-node": "npm run mocha -- out-tests --colors --reporter dot -t 10000",

"build-tests-rust": "npm run fable -- ../../../../tests/Rust/Fable.Tests.Rust.fsproj --outDir ./out-tests-rust --fableLib ./out-lib-rust --lang Rust",
"build-tests-dart": "npm run fable -- ../../../../tests/Dart/src/Fable.Tests.Dart.fsproj --outDir ./out-tests-dart --fableLib ./out-lib-dart --lang Dart",
Expand Down
2 changes: 1 addition & 1 deletion src/fable-standalone/test/bench/bench.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RollForward>Major</RollForward>
<DefineConstants>$(DefineConstants);DOTNET_FILE_SYSTEM</DefineConstants>
</PropertyGroup>
Expand Down
45 changes: 27 additions & 18 deletions src/fcs-fable/FSStrings.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ let resources =
( "ConstraintSolverMissingConstraint",
"A type parameter is missing a constraint '{0}'"
);
( "ConstraintSolverNullnessWarningEquivWithTypes",
"Nullness warning: The types '{0}' and '{1}' do not have equivalent nullability."
);
( "ConstraintSolverNullnessWarningWithTypes",
"Nullness warning: The types '{0}' and '{1}' do not have compatible nullability."
);
( "ConstraintSolverNullnessWarningWithType",
"Nullness warning: The type '{0}' does not support 'null'."
);
( "ConstraintSolverNullnessWarning",
"Nullness warning: {0}."
);
( "ConstraintSolverTypesNotInEqualityRelation1",
"The unit of measure '{0}' does not match the unit of measure '{1}'"
);
Expand Down Expand Up @@ -69,7 +81,7 @@ let resources =
"Duplicate definition of {0} '{1}'"
);
( "NameClash2",
"The {0} '{1}' can not be defined because the name '{2}' clashes with the {3} '{4}' in this type or module"
"The {0} '{1}' cannot be defined because the name '{2}' clashes with the {3} '{4}' in this type or module"
);
( "Duplicate1",
"Two members called '{0}' have the same signature"
Expand Down Expand Up @@ -105,7 +117,7 @@ let resources =
"A coercion from the value type \n {0} \nto the type \n {1} \nwill involve boxing. Consider using 'box' instead"
);
( "TypeIsImplicitlyAbstract",
"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."
"Non-abstract classes cannot contain abstract members. Either provide a default member implementation or add the '[<AbstractClass>]' attribute to your type."
);
( "NonRigidTypar1",
"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}'."
Expand Down Expand Up @@ -299,6 +311,9 @@ let resources =
( "Parser.TOKEN.BAR.RBRACE",
"symbol '|}'"
);
( "Parser.TOKEN.BAR_JUST_BEFORE_NULL",
"symbol '|' (directly before 'null')"
);
( "Parser.TOKEN.GREATER.RBRACE",
"symbol '>}'"
);
Expand Down Expand Up @@ -914,20 +929,11 @@ let resources =
( "MissingFields",
"The following fields require values: {0}"
);
( "ValueRestriction1",
"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."
( "ValueRestrictionFunction",
"""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."""
);
( "ValueRestriction2",
"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."
);
( "ValueRestriction3",
"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."
);
( "ValueRestriction4",
"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."
);
( "ValueRestriction5",
"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."
( "ValueRestriction",
"""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."""
);
( "RecoverableParseError",
"syntax error"
Expand All @@ -945,7 +951,7 @@ let resources =
"Override implementations should be given as part of the initial declaration of a type."
);
( "IntfImplInIntrinsicAugmentation",
"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."
"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."
);
( "IntfImplInExtrinsicAugmentation",
"Interface implementations should be given on the initial declaration of a type."
Expand All @@ -957,10 +963,10 @@ let resources =
"The type referenced through '{0}' is defined in an assembly that is not referenced. You must add a reference to assembly '{1}'."
);
( "HashIncludeNotAllowedInNonScript",
"#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'."
"#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'."
);
( "HashReferenceNotAllowedInNonScript",
"#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'."
"#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'."
);
( "HashDirectiveNotAllowedInNonScript",
"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'."
Expand Down Expand Up @@ -1007,6 +1013,9 @@ let resources =
( "ArgumentsInSigAndImplMismatch",
"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."
);
( "DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer",
"The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3}"
);
( "Parser.TOKEN.WHILE.BANG",
"keyword 'while!'"
);
Expand Down
9 changes: 8 additions & 1 deletion src/fcs-fable/SR.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
namespace FSharp.Compiler

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

module FSComp =
module SR =
let GetTextOpt (name: string) =
match SR.Resources.resources.TryGetValue(name) with
| true, value -> Some value
| _ -> None

module DiagnosticMessage =
type ResourceString<'T>(sfmt: string, fmt: string) =
member x.Format =
Expand Down
Loading
Loading