diff --git a/src/Compiler/Checking/CheckExpressions.fs b/src/Compiler/Checking/CheckExpressions.fs index 89253bd6783..9e632a62e43 100644 --- a/src/Compiler/Checking/CheckExpressions.fs +++ b/src/Compiler/Checking/CheckExpressions.fs @@ -7593,18 +7593,38 @@ and TcConstExpr cenv (overallTy: OverallTy) env m tpenv c = | Result [] | Exception _ -> error(Error(FSComp.SR.tcNumericLiteralRequiresModule modName, m)) | Result ((_, mref, _) :: _) -> + + let mkFunctionCall (name, constExpr) = + SynExpr.App (ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] name, SynExpr.Const (constExpr, m), m) + let expr = try match int32 s with - | 0 -> SynExpr.App (ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromZero", SynExpr.Const (SynConst.Unit, m), m) - | 1 -> SynExpr.App (ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromOne", SynExpr.Const (SynConst.Unit, m), m) - | i32 -> SynExpr.App (ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromInt32", SynExpr.Const (SynConst.Int32 i32, m), m) + | 0 -> mkFunctionCall ("FromZero", SynConst.Unit) + | 1 -> mkFunctionCall ("FromOne", SynConst.Unit) + | i32 -> mkFunctionCall ("FromInt32", SynConst.Int32 i32) with _ -> try let i64 = int64 s - SynExpr.App (ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromInt64", SynExpr.Const (SynConst.Int64 i64, m), m) + mkFunctionCall ("FromInt64", SynConst.Int64 i64) with _ -> - SynExpr.App (ExprAtomicFlag.Atomic, false, mkSynLidGet m [modName] "FromString", SynExpr.Const (SynConst.String (s, SynStringKind.Regular, m), m), m) + try + let res = Regex.Match(s, @"^-?0*(?\d+\.?\d*?)0*(?:$|[eE][+-]?(?\d+))") + let exp = res.Groups.["exp"] + let number = res.Groups.["number"] + let isNumberContainsDot = -1 <> number.Value.IndexOf '.' + let maxLen = if isNumberContainsDot then 16 else 15 + + if not res.Success || (not isNumberContainsDot && not exp.Success) then + mkFunctionCall ("FromString", SynConst.String (s, SynStringKind.Regular, m)) + elif (not exp.Success || int exp.Value <= 300) && number.Length <= maxLen then + let f64 = float s + mkFunctionCall ("FromFloat", SynConst.Double f64) + else + mkFunctionCall ("FromFloatString", SynConst.String (s, SynStringKind.Regular, m)) + + with _ -> + mkFunctionCall ("FromString", SynConst.String (s, SynStringKind.Regular, m)) if suffix <> "I" then expr diff --git a/src/Compiler/FSComp.txt b/src/Compiler/FSComp.txt index 25047f08e39..078e29911af 100644 --- a/src/Compiler/FSComp.txt +++ b/src/Compiler/FSComp.txt @@ -636,7 +636,7 @@ tcExpressionWithIfRequiresParenthesis,"This list or array expression includes an 781,tcConstructorRequiresArguments,"This object constructor requires arguments" 782,tcNewRequiresObjectConstructor,"'new' may only be used with object constructors" 783,tcAtLeastOneOverrideIsInvalid,"At least one override did not correctly implement its corresponding abstract member" -784,tcNumericLiteralRequiresModule,"This numeric literal requires that a module '%s' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope" +784,tcNumericLiteralRequiresModule,"This numeric literal requires that a module '%s' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope" 785,tcInvalidRecordConstruction,"Invalid record construction" 786,tcExpressionFormRequiresRecordTypes,"The expression form {{ expr with ... }} may only be used with record types. To build object types use {{ new Type(...) with ... }}" 787,tcInheritedTypeIsNotObjectModelType,"The inherited type is not an object model type" @@ -1035,7 +1035,7 @@ lexUnexpectedChar,"Unexpected character '%s'" 1153,lexInvalidFloat,"Invalid floating point number" 1154,lexOutsideDecimal,"This number is outside the allowable range for decimal literals" 1155,lexOutsideThirtyTwoBitFloat,"This number is outside the allowable range for 32-bit floats" -1156,lexInvalidNumericLiteral,"This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint)." +1156,lexInvalidNumericLiteral,"This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint)." 1157,lexInvalidByteLiteral,"This is not a valid byte literal" 1158,lexInvalidCharLiteral,"This is not a valid character literal" 1159,lexThisUnicodeOnlyInStringLiterals,"This Unicode encoding is only valid in string literals" @@ -1597,6 +1597,7 @@ featureEnforceAttributeTargets,"Enforce AttributeTargets" featureLowerInterpolatedStringToConcat,"Optimizes interpolated strings in certain cases, by lowering to concatenation" featureLowerIntegralRangesToFastLoops,"Optimizes certain uses of the integral range (..) and range-step (.. ..) operators to fast while-loops." featureLowerSimpleMappingsInComprehensionsToDirectCallsToMap,"Lowers [for x in xs -> f x] and [|for x in xs -> f x|] to calls to List.map and Array.map when xs is a list or an array, respectively." +featureExtendedNumericLiteral,"Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal" 3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation." 3355,tcNotAnIndexerNamedIndexingNotYetEnabled,"The value '%s' is not a function and does not support index notation." diff --git a/src/Compiler/Facilities/LanguageFeatures.fs b/src/Compiler/Facilities/LanguageFeatures.fs index 50b891335da..8bedebcf32f 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fs +++ b/src/Compiler/Facilities/LanguageFeatures.fs @@ -89,6 +89,7 @@ type LanguageFeature = | LowerInterpolatedStringToConcat | LowerIntegralRangesToFastLoops | LowerSimpleMappingsInComprehensionsToDirectCallsToMap + | ExtendedNumericLiteral /// LanguageVersion management type LanguageVersion(versionText) = @@ -205,6 +206,7 @@ type LanguageVersion(versionText) = LanguageFeature.LowerInterpolatedStringToConcat, previewVersion LanguageFeature.LowerIntegralRangesToFastLoops, previewVersion LanguageFeature.LowerSimpleMappingsInComprehensionsToDirectCallsToMap, previewVersion + LanguageFeature.ExtendedNumericLiteral, previewVersion ] static let defaultLanguageVersion = LanguageVersion("default") @@ -353,6 +355,7 @@ type LanguageVersion(versionText) = | LanguageFeature.LowerIntegralRangesToFastLoops -> FSComp.SR.featureLowerIntegralRangesToFastLoops () | LanguageFeature.LowerSimpleMappingsInComprehensionsToDirectCallsToMap -> FSComp.SR.featureLowerSimpleMappingsInComprehensionsToDirectCallsToMap () + | LanguageFeature.ExtendedNumericLiteral -> FSComp.SR.featureExtendedNumericLiteral () /// Get a version string associated with the given feature. static member GetFeatureVersionString feature = diff --git a/src/Compiler/Facilities/LanguageFeatures.fsi b/src/Compiler/Facilities/LanguageFeatures.fsi index 5cf1520db7f..fe577f3a99b 100644 --- a/src/Compiler/Facilities/LanguageFeatures.fsi +++ b/src/Compiler/Facilities/LanguageFeatures.fsi @@ -80,6 +80,7 @@ type LanguageFeature = | LowerInterpolatedStringToConcat | LowerIntegralRangesToFastLoops | LowerSimpleMappingsInComprehensionsToDirectCallsToMap + | ExtendedNumericLiteral /// LanguageVersion management type LanguageVersion = diff --git a/src/Compiler/SyntaxTree/LexHelpers.fs b/src/Compiler/SyntaxTree/LexHelpers.fs index 02d4da364d4..b4b2f248435 100644 --- a/src/Compiler/SyntaxTree/LexHelpers.fs +++ b/src/Compiler/SyntaxTree/LexHelpers.fs @@ -4,6 +4,7 @@ module internal FSharp.Compiler.Lexhelp open System open System.Text +open System.Text.RegularExpressions open Internal.Utilities open Internal.Utilities.Library @@ -303,6 +304,21 @@ let escape c = | 'r' -> '\r' | c -> c +let failsWhenExtendedNumericLiteralNotAvailable (langVersion: LanguageVersion) (s: string) (m: range) = + let isSeperatorInNewPlace = + Regex.IsMatch(s, "^[+-]?0[xob]_") + || Regex.IsMatch(s, "_[uU]?[luLsyfmMnINZQRG]$") + + let isExtendedUserNum s = + let isXInteger = Regex.IsMatch(s, "^[+-]?0[xob]") + let isFloat = Regex.IsMatch(s, @"[eE\.]") + let isUserNum = Regex.IsMatch(s, "[INZQRG]$") + + isUserNum && (isXInteger || isFloat) + + if isSeperatorInNewPlace || isExtendedUserNum s then + checkLanguageFeatureAndRecover langVersion LanguageFeature.ExtendedNumericLiteral m + //------------------------------------------------------------------------ // Keyword table //----------------------------------------------------------------------- diff --git a/src/Compiler/SyntaxTree/LexHelpers.fsi b/src/Compiler/SyntaxTree/LexHelpers.fsi index 616bfa8a6fd..d88dc5f4bca 100644 --- a/src/Compiler/SyntaxTree/LexHelpers.fsi +++ b/src/Compiler/SyntaxTree/LexHelpers.fsi @@ -117,6 +117,10 @@ val unicodeGraphLong: string -> LongUnicodeLexResult val escape: char -> char +/// fails when the input is a extended numeric literal (0x_1 or 0x1_l or 0x1I or 1.0I) if +/// the language of the lang version does not support ExtendedNumericLiteral +val failsWhenExtendedNumericLiteralNotAvailable: Features.LanguageVersion -> string -> range -> unit + exception ReservedKeyword of string * range module Keywords = diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index cd73aa454c2..efe54a9fe53 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -239,43 +239,46 @@ let ignored_op_char = '.' | '$' | '?' let separator = '_' let xinteger = - ( '0' ('x'| 'X') hex ((hex | separator)* hex)? - | '0' ('o'| 'O') (['0'-'7']) (((['0'-'7']) | separator)* (['0'-'7']))? - | '0' ('b'| 'B') (['0'-'1']) (((['0'-'1']) | separator)* (['0'-'1']))?) + ( '0' ('x'| 'X') separator* hex ((hex | separator)* hex)? + | '0' ('o'| 'O') separator* (['0'-'7']) (((['0'-'7']) | separator)* (['0'-'7']))? + | '0' ('b'| 'B') separator* (['0'-'1']) (((['0'-'1']) | separator)* (['0'-'1']))?) let integer = digit ((digit | separator)* digit)? -let int8 = integer 'y' +let integerPrefix = integer separator* +let xintegerPrefix = xinteger separator* -let uint8 = (xinteger | integer) 'u' 'y' +let int8 = integerPrefix 'y' -let int16 = integer 's' +let uint8 = (xintegerPrefix | integerPrefix) 'u' 'y' -let uint16 = (xinteger | integer) 'u' 's' +let int16 = integerPrefix 's' + +let uint16 = (xintegerPrefix | integerPrefix) 'u' 's' let int = integer -let int32 = integer 'l' +let int32 = integerPrefix 'l' -let uint32 = (xinteger | integer) 'u' +let uint32 = (xintegerPrefix | integerPrefix) 'u' -let uint32l = (xinteger | integer) 'u' 'l' +let uint32l = (xintegerPrefix | integerPrefix) 'u' 'l' -let nativeint = (xinteger | integer) 'n' +let nativeint = (xintegerPrefix | integerPrefix) 'n' -let unativeint = (xinteger | integer) 'u' 'n' +let unativeint = (xintegerPrefix | integerPrefix) 'u' 'n' -let int64 = (xinteger | integer) 'L' +let int64 = (xintegerPrefix | integerPrefix) 'L' -let uint64 = (xinteger | integer) ('u' | 'U') 'L' +let uint64 = (xintegerPrefix | integerPrefix) ('u' | 'U') 'L' -let xint8 = xinteger 'y' +let xint8 = xintegerPrefix 'y' -let xint16 = xinteger 's' +let xint16 = xintegerPrefix 's' let xint = xinteger -let xint32 = xinteger 'l' +let xint32 = xintegerPrefix 'l' let floatp = digit ((digit | separator)* digit)? '.' (digit ((digit | separator)* digit)?)? @@ -283,19 +286,21 @@ let floate = digit ((digit | separator)* digit)? ('.' (digit ((digit | separator let float = floatp | floate -let bignum = integer ('I' | 'N' | 'Z' | 'Q' | 'R' | 'G') +let floatPrefix = float separator* + +let bignum = (xintegerPrefix | integerPrefix | floatPrefix) ('I' | 'N' | 'Z' | 'Q' | 'R' | 'G') let ieee64 = float -let ieee32 = float ('f' | 'F') +let ieee32 = floatPrefix ('f' | 'F') -let ieee32_dotless_no_exponent = integer ('f' | 'F') +let ieee32_dotless_no_exponent = integerPrefix ('f' | 'F') -let decimal = (float | integer) ('m' | 'M') +let decimal = (floatPrefix | integerPrefix) ('m' | 'M') -let xieee32 = xinteger 'l' 'f' +let xieee32 = xintegerPrefix 'l' 'f' -let xieee64 = xinteger 'L' 'F' +let xieee64 = xintegerPrefix 'L' 'F' let escape_char = ('\\' ( '\\' | "\"" | '\'' | 'a' | 'f' | 'v' | 'n' | 't' | 'b' | 'r')) @@ -363,6 +368,7 @@ rule token (args: LexArgs) (skip: bool) = parse | int8 { let n = lexemeTrimRightToInt32 args lexbuf 1 + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange // Allow to parse as min_int. Allowed only because we parse '-' as an operator. if Ranges.isInt8BadMax n then INT8(SByte.MinValue, true (* 'true' = 'bad'*) ) else if n > int SByte.MaxValue || n < int SByte.MinValue then fail args lexbuf (FSComp.SR.lexOutsideEightBitSigned()) (INT8(0y, false)) @@ -370,16 +376,19 @@ rule token (args: LexArgs) (skip: bool) = parse | xint8 { let n = lexemeTrimRightToInt32 args lexbuf 1 + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange if n > int Byte.MaxValue || n < 0 then fail args lexbuf (FSComp.SR.lexOutsideEightBitSignedHex()) (INT8(0y, false)) else INT8(sbyte(byte(n)), false) } | uint8 { let n = lexemeTrimRightToInt32 args lexbuf 2 + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange if n > int Byte.MaxValue || n < 0 then fail args lexbuf (FSComp.SR.lexOutsideEightBitUnsigned()) (UINT8(0uy)) else UINT8(byte n) } | int16 { let n = lexemeTrimRightToInt32 args lexbuf 1 + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange // Allow to parse as min_int. Allowed only because we parse '-' as an operator. if Ranges.isInt16BadMax n then INT16(Int16.MinValue, true (* 'true' = 'bad'*) ) else if n > int Int16.MaxValue || n < int Int16.MinValue then fail args lexbuf (FSComp.SR.lexOutsideSixteenBitSigned()) (INT16(0s, false)) @@ -387,11 +396,13 @@ rule token (args: LexArgs) (skip: bool) = parse | xint16 { let n = lexemeTrimRightToInt32 args lexbuf 1 + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange if n > int UInt16.MaxValue || n < 0 then fail args lexbuf (FSComp.SR.lexOutsideSixteenBitSigned()) (INT16(0s,false)) else INT16(int16(uint16(n)), false) } | uint16 { let n = lexemeTrimRightToInt32 args lexbuf 2 + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange if n > int UInt16.MaxValue || n < 0 then fail args lexbuf (FSComp.SR.lexOutsideSixteenBitUnsigned()) (UINT16(0us)) else UINT16(uint16 n) } @@ -406,6 +417,7 @@ rule token (args: LexArgs) (skip: bool) = parse | xint | int { let s = removeUnderscores (lexeme lexbuf) + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange // Allow to parse as min_int. Allowed only because we parse '-' as an operator. if Ranges.isInt32BadMax s then INT32(Int32.MinValue, true (* 'true' = 'bad'*) ) else let n = @@ -416,6 +428,7 @@ rule token (args: LexArgs) (skip: bool) = parse | xint32 | int32 { let s = removeUnderscores (lexemeTrimRight lexbuf 1) + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange // Allow to parse as min_int. Allowed only because we parse '-' as an operator. if Ranges.isInt32BadMax s then INT32(Int32.MinValue, true (* 'true' = 'bad'*) ) else let n = @@ -426,6 +439,7 @@ rule token (args: LexArgs) (skip: bool) = parse | uint32 { let s = removeUnderscores (lexemeTrimRight lexbuf 1) + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange let n = try int64 s with _ -> fail args lexbuf (FSComp.SR.lexOutsideThirtyTwoBitUnsigned()) 0L if n > int64 UInt32.MaxValue || n < 0L then fail args lexbuf (FSComp.SR.lexOutsideThirtyTwoBitUnsigned()) (UINT32(0u)) else @@ -434,6 +448,7 @@ rule token (args: LexArgs) (skip: bool) = parse | uint32l { let s = removeUnderscores (lexemeTrimRight lexbuf 2) + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange let n = try int64 s with _ -> fail args lexbuf (FSComp.SR.lexOutsideThirtyTwoBitUnsigned()) 0L if n > int64 UInt32.MaxValue || n < 0L then fail args lexbuf (FSComp.SR.lexOutsideThirtyTwoBitUnsigned()) (UINT32(0u)) else @@ -441,6 +456,7 @@ rule token (args: LexArgs) (skip: bool) = parse | int64 { let s = removeUnderscores (lexemeTrimRight lexbuf 1) + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange // Allow to parse as min_int. Stupid but allowed because we parse '-' as an operator. if Ranges.isInt64BadMax s then INT64(Int64.MinValue, true (* 'true' = 'bad'*) ) else let n = @@ -450,12 +466,14 @@ rule token (args: LexArgs) (skip: bool) = parse | uint64 { let s = removeUnderscores (lexemeTrimRight lexbuf 2) + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange let n = try uint64 s with _ -> fail args lexbuf (FSComp.SR.lexOutsideSixtyFourBitUnsigned()) 0UL UINT64(n) } | nativeint { let s = removeUnderscores (lexemeTrimRight lexbuf 1) + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange // Allow to parse as min_nativeint. Stupid but allowed because we parse '-' as an operator. if Ranges.isInt64BadMax s then NATIVEINT(Int64.MinValue, true) else let n = @@ -465,24 +483,29 @@ rule token (args: LexArgs) (skip: bool) = parse | unativeint { try + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange UNATIVEINT(uint64 (removeUnderscores (lexemeTrimRight lexbuf 2))) with _ -> fail args lexbuf (FSComp.SR.lexOutsideNativeUnsigned()) (UNATIVEINT(0UL)) } | ieee32 - { IEEE32 (evalFloat args lexbuf) } + { failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange + IEEE32 (evalFloat args lexbuf) } | ieee32_dotless_no_exponent { if lexbuf.SupportsFeature LanguageFeature.DotlessFloat32Literal then + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange IEEE32 (evalFloat args lexbuf) else fail args lexbuf (FSComp.SR.lexInvalidFloat()) (IEEE32 0.0f) } | ieee64 - { IEEE64 (try float(lexeme lexbuf) with _ -> fail args lexbuf (FSComp.SR.lexInvalidFloat()) 0.0) } + { failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange + IEEE64 (try float(lexeme lexbuf) with _ -> fail args lexbuf (FSComp.SR.lexInvalidFloat()) 0.0) } | decimal { try + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange let s = removeUnderscores (lexemeTrimRight lexbuf 1) // This implements a range check for decimal literals let d = System.Decimal.Parse(s,System.Globalization.NumberStyles.AllowExponent ||| System.Globalization.NumberStyles.Number,System.Globalization.CultureInfo.InvariantCulture) @@ -492,6 +515,7 @@ rule token (args: LexArgs) (skip: bool) = parse } | xieee32 { + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange let s = removeUnderscores (lexemeTrimRight lexbuf 2) // Even though the intermediate step is an int64, display the "invalid float" message, since it will be less confusing to the user let n64 = (try (int64 s) with _ -> fail args lexbuf (FSComp.SR.lexInvalidFloat()) 0L) @@ -500,11 +524,13 @@ rule token (args: LexArgs) (skip: bool) = parse | xieee64 { + failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange let n64 = (try int64 (removeUnderscores (lexemeTrimRight lexbuf 2)) with _ -> fail args lexbuf (FSComp.SR.lexInvalidFloat()) 0L) IEEE64 (System.BitConverter.Int64BitsToDouble(n64)) } | bignum - { let s = lexeme lexbuf + { failsWhenExtendedNumericLiteralNotAvailable lexbuf.LanguageVersion (lexeme lexbuf) lexbuf.LexemeRange + let s = lexeme lexbuf BIGNUM (removeUnderscores (lexemeTrimRight lexbuf 1), s.[s.Length-1..s.Length-1]) } | (int | xint | float) ident_char+ diff --git a/src/Compiler/xlf/FSComp.txt.cs.xlf b/src/Compiler/xlf/FSComp.txt.cs.xlf index a4e8e281866..036187e85a5 100644 --- a/src/Compiler/xlf/FSComp.txt.cs.xlf +++ b/src/Compiler/xlf/FSComp.txt.cs.xlf @@ -337,6 +337,11 @@ rozšířené pevné vazby pro byref a GetPinnableReference + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. Rozšířená interpolace řetězců podobná nezpracovaným řetězcovým literálům jazyka C#. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - Tento číselný literál vyžaduje, aby modul {0} definující funkce FromZero, FromOne, FromInt32, FromInt64 a FromString byl v definičním oboru. + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + Tento číselný literál vyžaduje, aby modul {0} definující funkce FromZero, FromOne, FromInt32, FromInt64 a FromString byl v definičním oboru. @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - Toto není platný číselný literál. Platné číselné literály zahrnují hodnoty 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + Toto není platný číselný literál. Platné číselné literály zahrnují hodnoty 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). diff --git a/src/Compiler/xlf/FSComp.txt.de.xlf b/src/Compiler/xlf/FSComp.txt.de.xlf index f920991d5f4..6245bef0d2e 100644 --- a/src/Compiler/xlf/FSComp.txt.de.xlf +++ b/src/Compiler/xlf/FSComp.txt.de.xlf @@ -337,6 +337,11 @@ Erweiterte feste Bindungen für byref und GetPinnableReference + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. Erweiterte Zeichenfolgeninterpolation ähnlich wie bei C#-Rohzeichenfolgenliteralen. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - Für dieses numerische Literal muss sich das Modul "{0}" im Bereich befinden, das die Funktionen "FromZero", "FromOne", "FromInt32", "FromInt64" und "FromString" definiert. + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + Für dieses numerische Literal muss sich das Modul "{0}" im Bereich befinden, das die Funktionen "FromZero", "FromOne", "FromInt32", "FromInt64" und "FromString" definiert. @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - Dies ist kein gültiges numerisches Literal. Unter anderem sind die folgenden numerischen Literale gültig: 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + Dies ist kein gültiges numerisches Literal. Unter anderem sind die folgenden numerischen Literale gültig: 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). diff --git a/src/Compiler/xlf/FSComp.txt.es.xlf b/src/Compiler/xlf/FSComp.txt.es.xlf index f6054605ffa..9d192ac580d 100644 --- a/src/Compiler/xlf/FSComp.txt.es.xlf +++ b/src/Compiler/xlf/FSComp.txt.es.xlf @@ -337,6 +337,11 @@ enlaces fijos extendidos para byref y GetPinnableReference + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. Interpolación de cadena extendida similar a los literales de cadena sin formato de C#. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - Este literal numérico requiere que un módulo '{0}' que define las funciones FromZero, FromOne, FromInt32, FromInt64 y FromString esté en el ámbito. + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + Este literal numérico requiere que un módulo '{0}' que define las funciones FromZero, FromOne, FromInt32, FromInt64 y FromString esté en el ámbito. @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - Este literal numérico no es válido. Entre los literales numéricos válidos se incluyen 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + Este literal numérico no es válido. Entre los literales numéricos válidos se incluyen 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). diff --git a/src/Compiler/xlf/FSComp.txt.fr.xlf b/src/Compiler/xlf/FSComp.txt.fr.xlf index 5e9349ac3ae..3a8553278f8 100644 --- a/src/Compiler/xlf/FSComp.txt.fr.xlf +++ b/src/Compiler/xlf/FSComp.txt.fr.xlf @@ -337,6 +337,11 @@ liaisons fixes étendues pour byref et GetPinnableReference + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. Interpolation de chaîne étendue similaire aux littéraux de chaîne brute C#. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - Ce littéral numérique requiert qu'un module '{0}' définissant les fonctions FromZero, FromOne, FromInt32, FromInt64 et FromString se trouve dans la portée + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + Ce littéral numérique requiert qu'un module '{0}' définissant les fonctions FromZero, FromOne, FromInt32, FromInt64 et FromString se trouve dans la portée @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - Il ne s’agit pas d’un littéral numérique valide. Les littéraux numériques valides incluent 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1,0 (float/double), 1,0f (float32/single), 1,0 m (décimal), 1I (bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + Il ne s’agit pas d’un littéral numérique valide. Les littéraux numériques valides incluent 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1,0 (float/double), 1,0f (float32/single), 1,0 m (décimal), 1I (bigint). diff --git a/src/Compiler/xlf/FSComp.txt.it.xlf b/src/Compiler/xlf/FSComp.txt.it.xlf index b936cdc3642..1addd7ed109 100644 --- a/src/Compiler/xlf/FSComp.txt.it.xlf +++ b/src/Compiler/xlf/FSComp.txt.it.xlf @@ -337,6 +337,11 @@ binding fissi estesi per byref e GetPinnableReference + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. Interpolazione di stringa estesa simile ai valori letterali stringa non elaborati C#. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - Il valore letterale numerico richiede che nell'ambito sia presente un modulo '{0}' che definisce funzioni FromZero, FromOne, FromInt32, FromInt64 e FromString + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + Il valore letterale numerico richiede che nell'ambito sia presente un modulo '{0}' che definisce funzioni FromZero, FromOne, FromInt32, FromInt64 e FromString @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - Non è un valore letterale numerico valido. I valori letterali numerici validi includono 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint 32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1,0 (float/double), 1,0f (float32/single), 1,0m (decimale), 1I (bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + Non è un valore letterale numerico valido. I valori letterali numerici validi includono 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint 32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1,0 (float/double), 1,0f (float32/single), 1,0m (decimale), 1I (bigint). diff --git a/src/Compiler/xlf/FSComp.txt.ja.xlf b/src/Compiler/xlf/FSComp.txt.ja.xlf index add97ebcbee..d8768fc042c 100644 --- a/src/Compiler/xlf/FSComp.txt.ja.xlf +++ b/src/Compiler/xlf/FSComp.txt.ja.xlf @@ -337,6 +337,11 @@ byref と GetPinnableReference の拡張固定バインド + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. C# の生文字列リテラルに似た拡張文字列補間。 @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - 数値リテラルの場合、関数 FromZero、FromOne、FromInt32、FromInt64、および FromString を定義するモジュール '{0}' がスコープに含まれている必要があります + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + 数値リテラルの場合、関数 FromZero、FromOne、FromInt32、FromInt64、および FromString を定義するモジュール '{0}' がスコープに含まれている必要があります @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - これは有効な数値リテラルではありません。有効な数値リテラルには、1、0x1、0o1、 0b1、1l (int/int32)、1u (uint/uint32)、1L (int64)、1UL (uint64)、1s (int16)、1us (uint16)、1y (int8/sbyte)、1uy (uint8/byte)、1.0 (float/double)、1.0f (float32/single)、1.0m (10 進)、1I (bigint)。 + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + これは有効な数値リテラルではありません。有効な数値リテラルには、1、0x1、0o1、 0b1、1l (int/int32)、1u (uint/uint32)、1L (int64)、1UL (uint64)、1s (int16)、1us (uint16)、1y (int8/sbyte)、1uy (uint8/byte)、1.0 (float/double)、1.0f (float32/single)、1.0m (10 進)、1I (bigint)。 diff --git a/src/Compiler/xlf/FSComp.txt.ko.xlf b/src/Compiler/xlf/FSComp.txt.ko.xlf index 005109642a3..44621882ab8 100644 --- a/src/Compiler/xlf/FSComp.txt.ko.xlf +++ b/src/Compiler/xlf/FSComp.txt.ko.xlf @@ -337,6 +337,11 @@ byref 및 GetPinnableReference에 대한 확장된 고정 바인딩 + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. C# 원시 문자열 리터럴과 유사한 확장 문자열 보간입니다. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - 이 숫자 리터럴을 사용하려면 FromZero, FromOne, FromInt32, FromInt64 및 FromString 함수를 정의하는 '{0}' 모듈이 범위 내에 있어야 합니다. + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + 이 숫자 리터럴을 사용하려면 FromZero, FromOne, FromInt32, FromInt64 및 FromString 함수를 정의하는 '{0}' 모듈이 범위 내에 있어야 합니다. @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - 유효한 숫자 리터럴이 아닙니다. 유효한 숫자 리터럴은 1, 0x1, 0o1, 0b1, 1l(int/int32), 1u(uint/uint32), 1L(int64), 1UL(uint64), 1s(int16), 1us(uint16), 1y(int8/)입니다. sbyte), 1uy(uint8/byte), 1.0(float/double), 1.0f(float32/single), 1.0m(decimal), 1I(bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + 유효한 숫자 리터럴이 아닙니다. 유효한 숫자 리터럴은 1, 0x1, 0o1, 0b1, 1l(int/int32), 1u(uint/uint32), 1L(int64), 1UL(uint64), 1s(int16), 1us(uint16), 1y(int8/)입니다. sbyte), 1uy(uint8/byte), 1.0(float/double), 1.0f(float32/single), 1.0m(decimal), 1I(bigint). diff --git a/src/Compiler/xlf/FSComp.txt.pl.xlf b/src/Compiler/xlf/FSComp.txt.pl.xlf index b11a525807f..42a7f0d059c 100644 --- a/src/Compiler/xlf/FSComp.txt.pl.xlf +++ b/src/Compiler/xlf/FSComp.txt.pl.xlf @@ -337,6 +337,11 @@ rozszerzone powiązania stałe dla elementów byref i GetPinnableReference + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. Rozszerzona interpolacja ciągów podobna do literałów nieprzetworzonych ciągów języka C#. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - Ten literał liczbowy wymaga, aby moduł „{0}” definiujący funkcje FromZero, FromOne, FromInt32, FromInt64 i FromString mieścił się w zakresie + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + Ten literał liczbowy wymaga, aby moduł „{0}” definiujący funkcje FromZero, FromOne, FromInt32, FromInt64 i FromString mieścił się w zakresie @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - To nie jest prawidłowy literał liczbowy. Prawidłowe literały liczbowe to 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/bajt), 1,0 (float/double), 1,0f (float32/single), 1,0 m (dziesiętny), 1I (bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + To nie jest prawidłowy literał liczbowy. Prawidłowe literały liczbowe to 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/bajt), 1,0 (float/double), 1,0f (float32/single), 1,0 m (dziesiętny), 1I (bigint). diff --git a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf index 78b23fc160d..239f1de6403 100644 --- a/src/Compiler/xlf/FSComp.txt.pt-BR.xlf +++ b/src/Compiler/xlf/FSComp.txt.pt-BR.xlf @@ -337,6 +337,11 @@ associações fixas estendidas para byref e GetPinnableReference + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. Interpolação de cadeia de caracteres estendida semelhante a literais de cadeia de caracteres bruta C#. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - Este literal numérico requer que um módulo '{0}' que define funções FromZero, FromOne, FromInt32, FromInt64 e FromString esteja no escopo + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + Este literal numérico requer que um módulo '{0}' que define funções FromZero, FromOne, FromInt32, FromInt64 e FromString esteja no escopo @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - Este não é um literal numérico válido. Os literais numéricos válidos incluem 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/ sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + Este não é um literal numérico válido. Os literais numéricos válidos incluem 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/ sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). diff --git a/src/Compiler/xlf/FSComp.txt.ru.xlf b/src/Compiler/xlf/FSComp.txt.ru.xlf index 670b03ce32a..90789ae6b18 100644 --- a/src/Compiler/xlf/FSComp.txt.ru.xlf +++ b/src/Compiler/xlf/FSComp.txt.ru.xlf @@ -337,6 +337,11 @@ расширенные фиксированные привязки для byref и GetPinnableReference + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. Расширенная интерполяция строк, аналогичная литералам необработанных строк C#. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - Данный числовой литерал требует наличия в области модуля "{0}" определяющих функций FromZero, FromOne, FromInt32, FromInt64 и FromString + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + Данный числовой литерал требует наличия в области модуля "{0}" определяющих функций FromZero, FromOne, FromInt32, FromInt64 и FromString @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - Это значение не является допустимым числовым литералом. Допустимые числовые литералы: 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1,0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + Это значение не является допустимым числовым литералом. Допустимые числовые литералы: 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1,0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). diff --git a/src/Compiler/xlf/FSComp.txt.tr.xlf b/src/Compiler/xlf/FSComp.txt.tr.xlf index e0552438c26..8c39d291348 100644 --- a/src/Compiler/xlf/FSComp.txt.tr.xlf +++ b/src/Compiler/xlf/FSComp.txt.tr.xlf @@ -337,6 +337,11 @@ byref ve GetPinnableReference için genişletilmiş sabit bağlamalar + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. C# ham sabit değerli dizeye benzer genişletilmiş dize ilişkilendirmesi. @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - Bu sayısal sabit değer FromZero, FromOne, FromInt32, FromInt64 ve FromString işlevlerini tanımlayan '{0}' modülünün kapsamda olmasını gerektirir + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + Bu sayısal sabit değer FromZero, FromOne, FromInt32, FromInt64 ve FromString işlevlerini tanımlayan '{0}' modülünün kapsamda olmasını gerektirir @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - Bu, geçerli bir sayısal değişmez değer değil. Geçerli sayısal değişmez değerler şunları içerir: 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + Bu, geçerli bir sayısal değişmez değer değil. Geçerli sayısal değişmez değerler şunları içerir: 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf index f53a45b0200..82e25b125a8 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hans.xlf @@ -337,6 +337,11 @@ byref 和 GetPinnableReference 的扩展固定绑定 + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. 扩展字符串内插类似于 C# 原始字符串字面量。 @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - 此数值文本要求定义函数 FromZero、FromOne、FromInt32、FromInt64 和 FromString 的模块“{0}”位于范围内 + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + 此数值文本要求定义函数 FromZero、FromOne、FromInt32、FromInt64 和 FromString 的模块“{0}”位于范围内 @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - 这不是有效的数值文本。有效数值包括 1、0x1、0o1、0b1、1l (int/int32)、1u (uint/uint32)、1L (int64)、1UL (uint64)、1s (int16)、1us (uint16)、1y (int8/sbyte)、1uy (uint8/byte)、1.0 (float/double)、1.0f (float32/single)、1.0m (decimal)、1I (bigint)。 + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + 这不是有效的数值文本。有效数值包括 1、0x1、0o1、0b1、1l (int/int32)、1u (uint/uint32)、1L (int64)、1UL (uint64)、1s (int16)、1us (uint16)、1y (int8/sbyte)、1uy (uint8/byte)、1.0 (float/double)、1.0f (float32/single)、1.0m (decimal)、1I (bigint)。 diff --git a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf index a80e8852c30..f4500692c68 100644 --- a/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf +++ b/src/Compiler/xlf/FSComp.txt.zh-Hant.xlf @@ -337,6 +337,11 @@ ByRef 和 GetPinnableReference 的擴充固定繫結 + + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal + + Extended string interpolation similar to C# raw string literals. 類似於 C# 原始字串常值的擴充字串插補。 @@ -4608,8 +4613,8 @@ - This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - 這個數值常值要求定義函式 FromZero、FromOne、FromInt32、FromInt64 和 FromString 的模組 '{0}' 必須在範圍內 + This numeric literal requires that a module '{0}' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope + 這個數值常值要求定義函式 FromZero、FromOne、FromInt32、FromInt64 和 FromString 的模組 '{0}' 必須在範圍內 @@ -6453,8 +6458,8 @@ - This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint). - 這不是有效的數值常值。有效的數值常值包括 1, 0x1、0o1、0b1、1l (int/int32)、1u (uint/uint32)、1L (int64)、1UL (uint64)、1s (int16)、1us (uint16)、1y (int8/sbyte)、1uy (uint8/byte)、1.0 (float/double)、1.0f (float32/single)、1.0m (decimal)、1I (bigint)。 + This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint). + 這不是有效的數值常值。有效的數值常值包括 1, 0x1、0o1、0b1、1l (int/int32)、1u (uint/uint32)、1L (int64)、1UL (uint64)、1s (int16)、1us (uint16)、1y (int8/sbyte)、1uy (uint8/byte)、1.0 (float/double)、1.0f (float32/single)、1.0m (decimal)、1I (bigint)。 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/SimpleConstant.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/SimpleConstant.fs index b2e120d025c..c85f9706259 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/SimpleConstant.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/SimpleConstant.fs @@ -50,7 +50,7 @@ module SimpleConstant = |> withDiagnostics [ (Error 720, Line 10, Col 7, Line 10, Col 13, "Non-primitive numeric literal constants cannot be used in pattern matches because they can be mapped to multiple different types through the use of a NumericLiteral module. Consider using replacing with a variable, and use 'when = ' at the end of the match clause.") (Error 720, Line 11, Col 7, Line 11, Col 9, "Non-primitive numeric literal constants cannot be used in pattern matches because they can be mapped to multiple different types through the use of a NumericLiteral module. Consider using replacing with a variable, and use 'when = ' at the end of the match clause.") - (Error 784, Line 14, Col 17, Line 14, Col 19, "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope") + (Error 784, Line 14, Col 17, Line 14, Col 19, "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope") ] // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index 01057df5fa9..e544fbf9a10 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -12,26 +12,35 @@ module ``Numeric Literals`` = [] [] - [] [] - [] [] [] - [] [] [] [] - [] [] [] [] - [] let ``Invalid Numeric Literals`` literal = FSharp ("let x = " + literal) |> typecheck |> shouldFail |> withSingleDiagnostic (Error 1156, Line 1, Col 9, Line 1, Col (9 + (String.length literal)), - "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint).") + "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint).") + + [] + [] + [] + [] + [] + [] + let ``Invalid Numeric Literals In F#8`` literal = + FSharp ("let x = " + literal) + |> withLangVersion80 + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1156, Line 1, Col 9, Line 1, Col (9 + (String.length literal)), + "Feature 'Underscores in numeric literal after prefix or before suffix and Hexadecimal, octal, binary and floating custom numeric literal' is not available in F# 8.0. Please use language version 'PREVIEW' or greater.") [] let ``3_(dot)1415F is invalid numeric literal``() = @@ -39,7 +48,7 @@ module ``Numeric Literals`` = |> typecheck |> shouldFail |> withDiagnostics [ - (Error 1156, Line 1, Col 9, Line 1, Col 11, "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1I (bigint).") + (Error 1156, Line 1, Col 9, Line 1, Col 11, "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int/int32), 1u (uint/uint32), 1L (int64), 1UL (uint64), 1s (int16), 1us (uint16), 1y (int8/sbyte), 1uy (uint8/byte), 1.0 (float/double), 1.0f (float32/single), 1.0m (decimal), 1n (nativeint), 1un (unativeint), 1I (bigint).") (Error 599, Line 1, Col 11, Line 1, Col 12,"Missing qualification after '.'")] [] @@ -56,7 +65,7 @@ module ``Numeric Literals`` = |> typecheck |> shouldFail |> withSingleDiagnostic (Error 0784, Line 1, Col 9, Line 1, Col 11, - "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope") + "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope") [] let ``1N is invalid numeric literal in FSI``() = @@ -65,7 +74,7 @@ module ``Numeric Literals`` = let x = 1N """ [ - "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope"; + "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64, FromString, FromFloat and FromFloatString be in scope"; "Operation could not be completed due to earlier error" ]