Skip to content

Commit

Permalink
Updated FCS-Fable to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Dec 8, 2023
1 parent 58bed7a commit b95cdc3
Show file tree
Hide file tree
Showing 193 changed files with 14,949 additions and 10,971 deletions.
6 changes: 6 additions & 0 deletions src/fcs-fable/FSStrings.fs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,12 @@ let resources =
( "OverrideDoesntOverride4",
"The member '{0}' is specialized with 'unit' but 'unit' can't be used as return type of an abstract method parameterized on return type."
);
( "OverrideShouldBeStatic",
" Static member is expected."
);
( "OverrideShouldBeInstance",
" Non-static member is expected."
);
( "UnionCaseWrongArguments",
"This constructor is applied to {0} argument(s) but expects {1}"
);
Expand Down
19 changes: 14 additions & 5 deletions src/fcs-fable/System.Collections.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module Immutable =
type ImmutableArray<'T> =
static member CreateBuilder() = ResizeArray<'T>()

[<Sealed>]
type ImmutableHashSet<'T>(values: 'T seq) =
let xs = HashSet<'T>(values)

Expand Down Expand Up @@ -62,13 +63,21 @@ module Immutable =
member _.GetEnumerator(): IEnumerator<'T> =
xs.GetEnumerator()

type ImmutableDictionary<'Key, 'Value when 'Key: equality>(pairs: KeyValuePair<'Key, 'Value> seq) =
let xs = Dictionary<'Key, 'Value>()
do for pair in pairs do xs.Add(pair.Key, pair.Value)
[<Sealed>]
type ImmutableDictionary<'Key, 'Value when 'Key: equality>(xs: Dictionary<'Key, 'Value>) =
static member Create(comparer: IEqualityComparer<'Key>) =
ImmutableDictionary<'Key, 'Value>(Dictionary(comparer))

static member CreateRange(items) = ImmutableDictionary<'Key, 'Value>(items)
static member Empty = ImmutableDictionary<'Key, 'Value>(Array.empty)
static member CreateRange(items: IEnumerable<KeyValuePair<'Key, 'Value>>) =
let xs = Dictionary<'Key, 'Value>()
for pair in items do
xs.Add(pair.Key, pair.Value)
ImmutableDictionary<'Key, 'Value>(xs)

static member Empty =
ImmutableDictionary<'Key, 'Value>(Dictionary())

member _.IsEmpty = xs.Count = 0
member _.Item with get (key: 'Key): 'Value = xs[key]
member _.ContainsKey (key: 'Key) = xs.ContainsKey(key)

Expand Down
2 changes: 1 addition & 1 deletion src/fcs-fable/TcImports_shim.fs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ module TcImports =
XmlDocumentationInfo = None
}

let optdata = lazy (
let optdata = InterruptibleLazy(fun _ ->
match memoize_opt.Apply ccuName with
| None -> None
| Some data ->
Expand Down
20 changes: 17 additions & 3 deletions src/fcs-fable/codegen/FSComp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ type internal SR private() =
static member tcMeasureDeclarationsRequireStaticMembers() = (897, sprintf "Measure declarations may have only static members" )
static member tcStructsMayNotContainDoBindings() = (sprintf "Structs cannot contain 'do' bindings because the default constructor for structs would not execute these bindings" )
static member tcStructsMayNotContainLetBindings() = (901, sprintf "Structs cannot contain value definitions because the default constructor for structs will not execute these bindings. Consider adding additional arguments to the primary constructor for the type." )
static member tcStaticLetBindingsRequireClassesWithImplicitConstructors() = (902, sprintf "For F#7 and lower, static value definitions may only be used in types with a primary constructor ('type X(args) = ...'). To enable them in all other types, use language version 'preview'." )
static member tcStaticLetBindingsRequireClassesWithImplicitConstructors() = (902, sprintf "For F#7 and lower, static 'let','do' and 'member val' definitions may only be used in types with a primary constructor ('type X(args) = ...'). To enable them in all other types, use language version '8' or higher." )
static member tcMeasureDeclarationsRequireStaticMembersNotConstructors() = (904, sprintf "Measure declarations may have only static members: constructors are not available" )
static member tcMemberAndLocalClassBindingHaveSameName(a0 : System.String) = (905, sprintf "A member and a local class binding both have the name '%s'" a0)
static member tcTypeAbbreviationsCannotHaveInterfaceDeclaration() = (906, sprintf "Type abbreviations cannot have interface declarations" )
Expand Down Expand Up @@ -835,7 +835,7 @@ type internal SR private() =
static member ilStructLayoutAttributeCouldNotBeDecoded() = (992, sprintf "The StructLayout attribute could not be decoded" )
static member ilDefaultAugmentationAttributeCouldNotBeDecoded() = (993, sprintf "The DefaultAugmentation attribute could not be decoded" )
static member ilReflectedDefinitionsCannotUseSliceOperator() = (994, sprintf "Reflected definitions cannot contain uses of the prefix splice operator '%%'" )
static member packageManagerUnknown(a0 : System.String, a1 : System.String, a2 : System.String) = (998, sprintf "Package manager key '%s' was not registered in %s. Currently registered: %s. To learn more about extensions, visit: https://aka.ms/dotnetdepmanager" a0 a1 a2)
static member packageManagerUnknown(a0 : System.String, a1 : System.String, a2 : System.String) = (998, sprintf "Package manager key '%s' was not registered in %s. Currently registered: %s. You can provide extra path(s) by passing '--compilertool:<extensionsfolder>' to the command line. To learn more about extensions, visit: https://aka.ms/dotnetdepmanager" a0 a1 a2)
static member packageManagerError(a0 : System.String) = (999, sprintf "%s" a0)
static member optsProblemWithCodepage(a0 : System.Int32, a1 : System.String) = (1000, sprintf "Problem with codepage '%d': %s" a0 a1)
static member optsCopyright() = (sprintf "Copyright (c) Microsoft Corporation. All Rights Reserved." )
Expand Down Expand Up @@ -1571,6 +1571,10 @@ type internal SR private() =
static member featureWhileBang() = (sprintf "'while!' expression" )
static member featureExtendedFixedBindings() = (sprintf "extended fixed bindings for byref and GetPinnableReference" )
static member featurePreferStringGetPinnableReference() = (sprintf "prefer String.GetPinnableReference in fixed bindings" )
static member featurePreferExtensionMethodOverPlainProperty() = (sprintf "prefer extension method over plain property" )
static member featureWarningIndexedPropertiesGetSetSameType() = (sprintf "Indexed properties getter and setter must have the same type" )
static member featureChkTailCallAttrOnNonRec() = (sprintf "Raises warnings if the 'TailCall' attribute is used on non-recursive functions." )
static member featureUnionIsPropertiesVisible() = (sprintf "Union case test properties" )
static member tcNotAFunctionButIndexerNamedIndexingNotYetEnabled(a0 : System.String, a1 : System.String) = (3354, sprintf "This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." a0 a1)
static member tcNotAFunctionButIndexerIndexingNotYetEnabled() = (3354, sprintf "This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." )
static member tcNotAnIndexerNamedIndexingNotYetEnabled(a0 : System.String) = (3355, sprintf "The value '%s' is not a function and does not support index notation." a0)
Expand Down Expand Up @@ -1697,7 +1701,6 @@ type internal SR private() =
static member parsMissingKeyword(a0 : System.String) = (3568, sprintf "Missing keyword '%s'" a0)
static member chkNotTailRecursive(a0 : System.String) = (3569, sprintf "The member or function '%s' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way." a0)
static member tcAmbiguousDiscardDotLambda() = (3570, sprintf "The meaning of _ is ambiguous here. It cannot be used for a discarded variable and a function shorthand in the same scope." )
static member parsUnderScoreDotLambdaNonAtomic() = (3571, sprintf " _. shorthand syntax for lambda functions can only be used with atomic expressions. That means expressions with no whitespace unless enclosed in parentheses." )
static member featureAccessorFunctionShorthand() = (sprintf "underscore dot shorthand for accessor only function" )
static member parsConstraintIntersectionSyntaxUsedWithNonFlexibleType() = (3572, sprintf "Constraint intersection syntax may only be used with flexible types, e.g. '#IDisposable & #ISomeInterface'." )
static member tcStaticBindingInExtrinsicAugmentation() = (3573, sprintf "Static bindings cannot be added to extrinsic augmentations. Consider using a 'static member' instead." )
Expand All @@ -1707,4 +1710,15 @@ type internal SR private() =
static member chkCopyUpdateSyntaxInAnonRecords() = (3578, sprintf "This expression is an anonymous record, use {|...|} instead of {...}." )
static member alwaysUseTypedStringInterpolation() = (3579, sprintf "Interpolated string contains untyped identifiers. Adding typed format specifiers is recommended." )
static member tcUnexpectedFunTypeInUnionCaseField() = (3580, sprintf "Unexpected function type in union case field definition. If you intend the field to be a function, consider wrapping the function signature with parens, e.g. | Case of a -> b into | Case of (a -> b)." )
static member chkIndexedGetterAndSetterHaveSamePropertyType(a0 : System.String, a1 : System.String, a2 : System.String) = (3581, sprintf "An indexed property's getter and setter must have the same type. Property '%s' has getter of type '%s' but setter of type '%s'." a0 a1 a2)
static member tcInfoIfFunctionShadowsUnionCase() = (3582, sprintf "This is a function definition that shadows a union case. If this is what you want, ignore or suppress this warning. If you want it to be a union case deconstruction, add parentheses." )
static member unnecessaryParentheses() = (3583, sprintf "Parentheses can be removed." )
static member tcDotLambdaAtNotSupportedExpression() = (3584, sprintf "Shorthand lambda syntax is only supported for atomic expressions, such as method, property, field or indexer on the implied '_' argument. For example: 'let f = _.Length'." )
static member tcStructUnionMultiCaseFieldsSameType() = (3585, sprintf "If a multicase union type is a struct, then all fields with the same name must be of the same type. This rule applies also to the generated 'Item' name in case of unnamed fields." )
static member featureReuseSameFieldsInStructUnions() = (sprintf "Share underlying fields in a [<Struct>] discriminated union as long as they have same name and type" )
static member tcNoStaticMemberFoundForOverride() = (3855, sprintf "No static abstract member was found that corresponds to this override" )
static member tcNoStaticPropertyFoundForOverride() = (3859, sprintf "No static abstract property was found that corresponds to this override" )
static member chkStaticMembersOnObjectExpressions() = (3860, sprintf "Object expressions cannot implement interfaces with static abstract members or declare static members." )
static member chkTailCallAttrOnNonRec() = (3861, sprintf "The TailCall attribute should only be applied to recursive functions." )
static member parsStaticMemberImcompleteSyntax() = (3862, sprintf "Incomplete declaration of a static construct. Use 'static let','static do','static member' or 'static val' for declaration." )
static member parsExpectingField() = (3863, sprintf "Expecting record field" )
20 changes: 10 additions & 10 deletions src/fcs-fable/codegen/illex.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ let kwdInstrTable =
(let t = HashMultiMap(1000, HashIdentity.Structural)
List.iter t.Add (Lazy.force keywords);
let addTable f l = List.iter (fun (x,i) -> t.Add (String.concat "." x,f i)) (Lazy.force l)
addTable (fun i -> INSTR_NONE i) NoArgInstrs;
addTable (fun i -> INSTR_I i) Int32Instrs;
addTable (fun i -> INSTR_I32_I32 i) Int32Int32Instrs;
addTable (fun i -> INSTR_I8 i) Int64Instrs;
addTable (fun i -> INSTR_R i) DoubleInstrs;
addTable (fun i -> INSTR_TYPE i) TypeInstrs;
addTable (fun i -> INSTR_INT_TYPE i) IntTypeInstrs;
addTable (fun i -> INSTR_VALUETYPE i) ValueTypeInstrs;
addTable (fun i -> INSTR_STRING i) StringInstrs;
addTable (fun i -> INSTR_TOK i) TokenInstrs;
addTable (INSTR_NONE) NoArgInstrs;
addTable (INSTR_I) Int32Instrs;
addTable (INSTR_I32_I32) Int32Int32Instrs;
addTable (INSTR_I8) Int64Instrs;
addTable (INSTR_R) DoubleInstrs;
addTable (INSTR_TYPE) TypeInstrs;
addTable (INSTR_INT_TYPE) IntTypeInstrs;
addTable (INSTR_VALUETYPE) ValueTypeInstrs;
addTable (INSTR_STRING) StringInstrs;
addTable (INSTR_TOK) TokenInstrs;
t)

let kwdOrInstr s = (Lazy.force kwdInstrTable).[s] (* words *)
Expand Down
Loading

0 comments on commit b95cdc3

Please sign in to comment.