зеркало из https://github.com/dotnet/fsharp.git
Merge branch 'release/dev17.5' of https://github.com/dotnet/fsharp into release/dev17.5
This commit is contained in:
Коммит
2e92791cec
|
@ -3,7 +3,7 @@
|
|||
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
|
||||
#-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
ARG VARIANT=7.0-bullseye-slim
|
||||
ARG VARIANT=7.0.100-bullseye-slim-amd64
|
||||
FROM mcr.microsoft.com/dotnet/sdk:${VARIANT}
|
||||
|
||||
# Avoid warnings by switching to noninteractive
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"args": {
|
||||
// Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0, 7.0
|
||||
// Append -bullseye(-slim), -focal, or -jammy to pin to an OS version.
|
||||
"VARIANT": "7.0-bullseye-slim"
|
||||
"VARIANT": "7.0.100-bullseye-slim-amd64"
|
||||
}
|
||||
},
|
||||
"hostRequirements": {
|
||||
|
|
|
@ -3,10 +3,16 @@
|
|||
"version": "0.2.0",
|
||||
"inputs": [
|
||||
{
|
||||
"id": "argsPrompt",
|
||||
"id": "fscArgsPrompt",
|
||||
"description": "Enter arguments for fsc",
|
||||
"default": "",
|
||||
"type": "promptString",
|
||||
},
|
||||
{
|
||||
"id": "fsiArgsPrompt",
|
||||
"description": "Enter arguments for fsi (optional)",
|
||||
"default": "",
|
||||
"type": "promptString",
|
||||
}
|
||||
],
|
||||
"configurations": [
|
||||
|
@ -18,6 +24,9 @@
|
|||
// "preLaunchTask": "Build (Debug)",
|
||||
// If you have changed target frameworks, make sure to update the program p
|
||||
"program": "${workspaceFolder}/artifacts/bin/fsi/Debug/net7.0/fsi.dll",
|
||||
"args": [
|
||||
"${input:fsiArgsPrompt}"
|
||||
],
|
||||
"cwd": "${workspaceFolder}/src",
|
||||
"console": "integratedTerminal", // This is the default to be able to run in Codespaces.
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
|
@ -44,7 +53,7 @@
|
|||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/artifacts/bin/fsc/Debug/net7.0/fsc.dll",
|
||||
"args": [
|
||||
"${input:argsPrompt}"
|
||||
"${input:fscArgsPrompt}"
|
||||
],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "integratedTerminal", // This is the default to be able to run in Codespaces.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
},
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Build (Debug)",
|
||||
"label": "Full Build (Debug)",
|
||||
"command": "./build.sh",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
|
@ -23,12 +23,16 @@
|
|||
],
|
||||
"windows": {
|
||||
"command": "${workspaceFolder}/Build.cmd",
|
||||
"args": [
|
||||
"-c Debug",
|
||||
"-noVisualStudio"
|
||||
],
|
||||
},
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": "build",
|
||||
},
|
||||
{
|
||||
"label": "Build (Release)",
|
||||
"label": "Full Build (Release)",
|
||||
"command": "./build.sh",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
|
@ -36,10 +40,27 @@
|
|||
],
|
||||
"windows": {
|
||||
"command": "${workspaceFolder}/Build.cmd",
|
||||
"args": [
|
||||
"-c Release",
|
||||
"-noVisualStudio"
|
||||
],
|
||||
},
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": "build",
|
||||
},
|
||||
{
|
||||
"label": "Rebuild (Debug)",
|
||||
"command": "dotnet",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
"build",
|
||||
"-c",
|
||||
"Debug",
|
||||
"${workspaceFolder}/FSharp.sln"
|
||||
],
|
||||
"problemMatcher": "$msCompile",
|
||||
"group": "build",
|
||||
},
|
||||
{
|
||||
"label": "Update xlf files",
|
||||
"command": "./build.sh",
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
<MicrosoftNETCoreILAsmVersion>5.0.0-preview.7.20364.11</MicrosoftNETCoreILAsmVersion>
|
||||
<MicrosoftNETTestSdkVersion>16.11.0</MicrosoftNETTestSdkVersion>
|
||||
<MicrosoftWin32RegistryVersion>5.0.0</MicrosoftWin32RegistryVersion>
|
||||
<NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion>
|
||||
<NewtonsoftJsonVersion>13.0.2</NewtonsoftJsonVersion>
|
||||
<NUnitVersion>3.13.2</NUnitVersion>
|
||||
<NUnit3TestAdapterVersion>4.1.0</NUnit3TestAdapterVersion>
|
||||
<NUnitLiteVersion>3.11.0</NUnitLiteVersion>
|
||||
|
|
|
@ -7165,13 +7165,14 @@ and TcInterpolatedStringExpr cenv (overallTy: OverallTy) env m tpenv (parts: Syn
|
|||
// Type check the expressions filling the holes
|
||||
|
||||
if List.isEmpty synFillExprs then
|
||||
let str = mkString g m printfFormatString
|
||||
|
||||
if isString then
|
||||
let sb = System.Text.StringBuilder(printfFormatString).Replace("%%", "%")
|
||||
let str = mkString g m (sb.ToString())
|
||||
TcPropagatingExprLeafThenConvert cenv overallTy g.string_ty env (* true *) m (fun () ->
|
||||
str, tpenv
|
||||
)
|
||||
else
|
||||
let str = mkString g m printfFormatString
|
||||
mkCallNewFormat g m printerTy printerArgTy printerResidueTy printerResultTy printerTupleTy str, tpenv
|
||||
else
|
||||
// Type check the expressions filling the holes
|
||||
|
|
|
@ -2693,6 +2693,7 @@ let rec ResolveLongIdentInTypePrim (ncenv: NameResolver) nenv lookupKind (resInf
|
|||
|
||||
match nestedSearchAccessible with
|
||||
| Result res when not (isNil res) -> nestedSearchAccessible
|
||||
| Exception _ -> nestedSearchAccessible
|
||||
| _ ->
|
||||
let suggestMembers (addToBuffer: string -> unit) =
|
||||
for p in ExtensionPropInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv None LookupIsInstance.Ambivalent ad m ty do
|
||||
|
|
|
@ -581,7 +581,7 @@ let SetDeterministicSwitch (tcConfigB: TcConfigBuilder) switch =
|
|||
|
||||
let SetReferenceAssemblyOnlySwitch (tcConfigB: TcConfigBuilder) switch =
|
||||
match tcConfigB.emitMetadataAssembly with
|
||||
| MetadataAssemblyGeneration.None ->
|
||||
| MetadataAssemblyGeneration.None when tcConfigB.standalone = false && tcConfigB.extraStaticLinkRoots.IsEmpty ->
|
||||
tcConfigB.emitMetadataAssembly <-
|
||||
if (switch = OptionSwitch.On) then
|
||||
MetadataAssemblyGeneration.ReferenceOnly
|
||||
|
@ -591,7 +591,7 @@ let SetReferenceAssemblyOnlySwitch (tcConfigB: TcConfigBuilder) switch =
|
|||
|
||||
let SetReferenceAssemblyOutSwitch (tcConfigB: TcConfigBuilder) outputPath =
|
||||
match tcConfigB.emitMetadataAssembly with
|
||||
| MetadataAssemblyGeneration.None ->
|
||||
| MetadataAssemblyGeneration.None when tcConfigB.standalone = false && tcConfigB.extraStaticLinkRoots.IsEmpty ->
|
||||
if FileSystem.IsInvalidPathShim outputPath then
|
||||
error (Error(FSComp.SR.optsInvalidRefOut (), rangeCmdArgs))
|
||||
else
|
||||
|
@ -1304,9 +1304,12 @@ let advancedFlagsFsc tcConfigB =
|
|||
"standalone",
|
||||
tagNone,
|
||||
OptionUnit(fun _ ->
|
||||
tcConfigB.openDebugInformationForLaterStaticLinking <- true
|
||||
tcConfigB.standalone <- true
|
||||
tcConfigB.implicitlyResolveAssemblies <- true),
|
||||
match tcConfigB.emitMetadataAssembly with
|
||||
| MetadataAssemblyGeneration.None ->
|
||||
tcConfigB.openDebugInformationForLaterStaticLinking <- true
|
||||
tcConfigB.standalone <- true
|
||||
tcConfigB.implicitlyResolveAssemblies <- true
|
||||
| _ -> error (Error(FSComp.SR.optsInvalidRefAssembly (), rangeCmdArgs))),
|
||||
None,
|
||||
Some(FSComp.SR.optsStandalone ())
|
||||
)
|
||||
|
@ -1315,8 +1318,11 @@ let advancedFlagsFsc tcConfigB =
|
|||
"staticlink",
|
||||
tagFile,
|
||||
OptionString(fun s ->
|
||||
tcConfigB.extraStaticLinkRoots <- tcConfigB.extraStaticLinkRoots @ [ s ]
|
||||
tcConfigB.implicitlyResolveAssemblies <- true),
|
||||
match tcConfigB.emitMetadataAssembly with
|
||||
| MetadataAssemblyGeneration.None ->
|
||||
tcConfigB.extraStaticLinkRoots <- tcConfigB.extraStaticLinkRoots @ [ s ]
|
||||
tcConfigB.implicitlyResolveAssemblies <- true
|
||||
| _ -> error (Error(FSComp.SR.optsInvalidRefAssembly (), rangeCmdArgs))),
|
||||
None,
|
||||
Some(FSComp.SR.optsStaticlink ())
|
||||
)
|
||||
|
|
|
@ -514,10 +514,6 @@ let StaticLink (ctok, tcConfig: TcConfig, tcImports: TcImports, ilGlobals: ILGlo
|
|||
id
|
||||
else
|
||||
(fun ilxMainModule ->
|
||||
match tcConfig.emitMetadataAssembly with
|
||||
| MetadataAssemblyGeneration.None -> ()
|
||||
| _ -> error (Error(FSComp.SR.optsInvalidRefAssembly (), rangeCmdArgs))
|
||||
|
||||
ReportTime tcConfig "Find assembly references"
|
||||
|
||||
let dependentILModules =
|
||||
|
|
|
@ -1165,7 +1165,7 @@ fscTooManyErrors,"Exiting - too many errors"
|
|||
2025,fscAssemblyWildcardAndDeterminism,"An %s specified version '%s', but this value is a wildcard, and you have requested a deterministic build, these are in conflict."
|
||||
2028,optsInvalidPathMapFormat,"Invalid path map. Mappings must be comma separated and of the format 'path=sourcePath'"
|
||||
2029,optsInvalidRefOut,"Invalid reference assembly path'"
|
||||
2030,optsInvalidRefAssembly,"Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together."
|
||||
2030,optsInvalidRefAssembly,"Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'."
|
||||
3000,etIllegalCharactersInNamespaceName,"Character '%s' is not allowed in provided namespace name '%s'"
|
||||
3001,etNullOrEmptyMemberName,"The provided type '%s' returned a member with a null or empty member name"
|
||||
3002,etNullMember,"The provided type '%s' returned a null member"
|
||||
|
@ -1558,6 +1558,7 @@ featureLowercaseDUWhenRequireQualifiedAccess,"Allow lowercase DU when RequireQua
|
|||
featureMatchNotAllowedForUnionCaseWithNoData,"Pattern match discard is not allowed for union case that takes no data."
|
||||
featureCSharpExtensionAttributeNotRequired,"Allow implicit Extension attribute on declaring types, modules"
|
||||
featureErrorForNonVirtualMembersOverrides,"Raises errors for non-virtual members overrides"
|
||||
featureArithmeticInLiterals,"Allow arithmetic and logical operations in literals"
|
||||
3353,fsiInvalidDirective,"Invalid directive '#%s %s'"
|
||||
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."
|
||||
|
|
|
@ -57,6 +57,7 @@ type LanguageFeature =
|
|||
| MatchNotAllowedForUnionCaseWithNoData
|
||||
| CSharpExtensionAttributeNotRequired
|
||||
| ErrorForNonVirtualMembersOverrides
|
||||
| ArithmeticInLiterals
|
||||
|
||||
/// LanguageVersion management
|
||||
type LanguageVersion(versionText) =
|
||||
|
@ -130,6 +131,7 @@ type LanguageVersion(versionText) =
|
|||
LanguageFeature.MatchNotAllowedForUnionCaseWithNoData, previewVersion
|
||||
LanguageFeature.CSharpExtensionAttributeNotRequired, previewVersion
|
||||
LanguageFeature.ErrorForNonVirtualMembersOverrides, previewVersion
|
||||
LanguageFeature.ArithmeticInLiterals, previewVersion
|
||||
|
||||
]
|
||||
|
||||
|
@ -238,8 +240,9 @@ type LanguageVersion(versionText) =
|
|||
| LanguageFeature.InterfacesWithAbstractStaticMembers -> FSComp.SR.featureInterfacesWithAbstractStaticMembers ()
|
||||
| LanguageFeature.SelfTypeConstraints -> FSComp.SR.featureSelfTypeConstraints ()
|
||||
| LanguageFeature.MatchNotAllowedForUnionCaseWithNoData -> FSComp.SR.featureMatchNotAllowedForUnionCaseWithNoData ()
|
||||
| LanguageFeature.CSharpExtensionAttributeNotRequired -> FSComp.SR.featureCSharpExtensionAttributeNotRequired ()
|
||||
| LanguageFeature.ErrorForNonVirtualMembersOverrides -> FSComp.SR.featureErrorForNonVirtualMembersOverrides ()
|
||||
| LanguageFeature.CSharpExtensionAttributeNotRequired -> FSComp.SR.featureCSharpExtensionAttributeNotRequired ()
|
||||
| LanguageFeature.ErrorForNonVirtualMembersOverrides -> FSComp.SR.featureErrorForNonVirtualMembersOverrides ()
|
||||
| LanguageFeature.ArithmeticInLiterals -> FSComp.SR.featureArithmeticInLiterals ()
|
||||
|
||||
/// Get a version string associated with the given feature.
|
||||
static member GetFeatureVersionString feature =
|
||||
|
|
|
@ -47,6 +47,7 @@ type LanguageFeature =
|
|||
| MatchNotAllowedForUnionCaseWithNoData
|
||||
| CSharpExtensionAttributeNotRequired
|
||||
| ErrorForNonVirtualMembersOverrides
|
||||
| ArithmeticInLiterals
|
||||
|
||||
/// LanguageVersion management
|
||||
type LanguageVersion =
|
||||
|
|
|
@ -1485,6 +1485,8 @@ type TcGlobals(
|
|||
member val unchecked_unary_not_vref = ValRefForIntrinsic v_unchecked_unary_not_info
|
||||
member val unchecked_subtraction_vref = ValRefForIntrinsic v_unchecked_subtraction_info
|
||||
member val unchecked_multiply_vref = ValRefForIntrinsic v_unchecked_multiply_info
|
||||
member val unchecked_division_vref = ValRefForIntrinsic v_unchecked_division_info
|
||||
member val unchecked_modulus_vref = ValRefForIntrinsic v_unchecked_modulus_info
|
||||
member val unchecked_defaultof_vref = ValRefForIntrinsic v_unchecked_defaultof_info
|
||||
member val refcell_deref_vref = ValRefForIntrinsic v_refcell_deref_info
|
||||
member val refcell_assign_vref = ValRefForIntrinsic v_refcell_assign_info
|
||||
|
|
|
@ -3742,6 +3742,28 @@ let (|SpecificUnopExpr|_|) g vrefReqd expr =
|
|||
| UnopExpr g (vref, arg1) when valRefEq g vref vrefReqd -> Some arg1
|
||||
| _ -> None
|
||||
|
||||
let (|SignedConstExpr|_|) expr =
|
||||
match expr with
|
||||
| Expr.Const (Const.Int32 _, _, _)
|
||||
| Expr.Const (Const.SByte _, _, _)
|
||||
| Expr.Const (Const.Int16 _, _, _)
|
||||
| Expr.Const (Const.Int64 _, _, _)
|
||||
| Expr.Const (Const.Single _, _, _)
|
||||
| Expr.Const (Const.Double _, _, _) -> Some ()
|
||||
| _ -> None
|
||||
|
||||
let (|IntegerConstExpr|_|) expr =
|
||||
match expr with
|
||||
| Expr.Const (Const.Int32 _, _, _)
|
||||
| Expr.Const (Const.SByte _, _, _)
|
||||
| Expr.Const (Const.Int16 _, _, _)
|
||||
| Expr.Const (Const.Int64 _, _, _)
|
||||
| Expr.Const (Const.Byte _, _, _)
|
||||
| Expr.Const (Const.UInt16 _, _, _)
|
||||
| Expr.Const (Const.UInt32 _, _, _)
|
||||
| Expr.Const (Const.UInt64 _, _, _) -> Some ()
|
||||
| _ -> None
|
||||
|
||||
let (|SpecificBinopExpr|_|) g vrefReqd expr =
|
||||
match expr with
|
||||
| BinopExpr g (vref, arg1, arg2) when valRefEq g vref vrefReqd -> Some (arg1, arg2)
|
||||
|
@ -9647,12 +9669,46 @@ let IsSimpleSyntacticConstantExpr g inputExpr =
|
|||
checkExpr vrefs e
|
||||
|
||||
checkExpr Set.empty inputExpr
|
||||
|
||||
let EvalArithBinOp (opInt8, opInt16, opInt32, opInt64, opUInt8, opUInt16, opUInt32, opUInt64) (arg1: Expr) (arg2: Expr) =
|
||||
// At compile-time we check arithmetic
|
||||
|
||||
let EvalArithShiftOp (opInt8, opInt16, opInt32, opInt64, opUInt8, opUInt16, opUInt32, opUInt64) (arg1: Expr) (arg2: Expr) =
|
||||
// At compile-time we check arithmetic
|
||||
let m = unionRanges arg1.Range arg2.Range
|
||||
try
|
||||
match arg1, arg2 with
|
||||
try
|
||||
match arg1, arg2 with
|
||||
| Expr.Const (Const.Int32 x1, _, ty), Expr.Const (Const.Int32 shift, _, _) -> Expr.Const (Const.Int32 (opInt32 x1 shift), m, ty)
|
||||
| Expr.Const (Const.SByte x1, _, ty), Expr.Const (Const.Int32 shift, _, _) -> Expr.Const (Const.SByte (opInt8 x1 shift), m, ty)
|
||||
| Expr.Const (Const.Int16 x1, _, ty), Expr.Const (Const.Int32 shift, _, _) -> Expr.Const (Const.Int16 (opInt16 x1 shift), m, ty)
|
||||
| Expr.Const (Const.Int64 x1, _, ty), Expr.Const (Const.Int32 shift, _, _) -> Expr.Const (Const.Int64 (opInt64 x1 shift), m, ty)
|
||||
| Expr.Const (Const.Byte x1, _, ty), Expr.Const (Const.Int32 shift, _, _) -> Expr.Const (Const.Byte (opUInt8 x1 shift), m, ty)
|
||||
| Expr.Const (Const.UInt16 x1, _, ty), Expr.Const (Const.Int32 shift, _, _) -> Expr.Const (Const.UInt16 (opUInt16 x1 shift), m, ty)
|
||||
| Expr.Const (Const.UInt32 x1, _, ty), Expr.Const (Const.Int32 shift, _, _) -> Expr.Const (Const.UInt32 (opUInt32 x1 shift), m, ty)
|
||||
| Expr.Const (Const.UInt64 x1, _, ty), Expr.Const (Const.Int32 shift, _, _) -> Expr.Const (Const.UInt64 (opUInt64 x1 shift), m, ty)
|
||||
| _ -> error (Error ( FSComp.SR.tastNotAConstantExpression(), m))
|
||||
with :? System.OverflowException -> error (Error ( FSComp.SR.tastConstantExpressionOverflow(), m))
|
||||
|
||||
let EvalArithUnOp (opInt8, opInt16, opInt32, opInt64, opUInt8, opUInt16, opUInt32, opUInt64, opSingle, opDouble) (arg1: Expr) =
|
||||
// At compile-time we check arithmetic
|
||||
let m = arg1.Range
|
||||
try
|
||||
match arg1 with
|
||||
| Expr.Const (Const.Int32 x1, _, ty) -> Expr.Const (Const.Int32 (opInt32 x1), m, ty)
|
||||
| Expr.Const (Const.SByte x1, _, ty) -> Expr.Const (Const.SByte (opInt8 x1), m, ty)
|
||||
| Expr.Const (Const.Int16 x1, _, ty) -> Expr.Const (Const.Int16 (opInt16 x1), m, ty)
|
||||
| Expr.Const (Const.Int64 x1, _, ty) -> Expr.Const (Const.Int64 (opInt64 x1), m, ty)
|
||||
| Expr.Const (Const.Byte x1, _, ty) -> Expr.Const (Const.Byte (opUInt8 x1), m, ty)
|
||||
| Expr.Const (Const.UInt16 x1, _, ty) -> Expr.Const (Const.UInt16 (opUInt16 x1), m, ty)
|
||||
| Expr.Const (Const.UInt32 x1, _, ty) -> Expr.Const (Const.UInt32 (opUInt32 x1), m, ty)
|
||||
| Expr.Const (Const.UInt64 x1, _, ty) -> Expr.Const (Const.UInt64 (opUInt64 x1), m, ty)
|
||||
| Expr.Const (Const.Single x1, _, ty) -> Expr.Const (Const.Single (opSingle x1), m, ty)
|
||||
| Expr.Const (Const.Double x1, _, ty) -> Expr.Const (Const.Double (opDouble x1), m, ty)
|
||||
| _ -> error (Error ( FSComp.SR.tastNotAConstantExpression(), m))
|
||||
with :? System.OverflowException -> error (Error ( FSComp.SR.tastConstantExpressionOverflow(), m))
|
||||
|
||||
let EvalArithBinOp (opInt8, opInt16, opInt32, opInt64, opUInt8, opUInt16, opUInt32, opUInt64, opSingle, opDouble) (arg1: Expr) (arg2: Expr) =
|
||||
// At compile-time we check arithmetic
|
||||
let m = unionRanges arg1.Range arg2.Range
|
||||
try
|
||||
match arg1, arg2 with
|
||||
| Expr.Const (Const.Int32 x1, _, ty), Expr.Const (Const.Int32 x2, _, _) -> Expr.Const (Const.Int32 (opInt32 x1 x2), m, ty)
|
||||
| Expr.Const (Const.SByte x1, _, ty), Expr.Const (Const.SByte x2, _, _) -> Expr.Const (Const.SByte (opInt8 x1 x2), m, ty)
|
||||
| Expr.Const (Const.Int16 x1, _, ty), Expr.Const (Const.Int16 x2, _, _) -> Expr.Const (Const.Int16 (opInt16 x1 x2), m, ty)
|
||||
|
@ -9661,11 +9717,18 @@ let EvalArithBinOp (opInt8, opInt16, opInt32, opInt64, opUInt8, opUInt16, opUInt
|
|||
| Expr.Const (Const.UInt16 x1, _, ty), Expr.Const (Const.UInt16 x2, _, _) -> Expr.Const (Const.UInt16 (opUInt16 x1 x2), m, ty)
|
||||
| Expr.Const (Const.UInt32 x1, _, ty), Expr.Const (Const.UInt32 x2, _, _) -> Expr.Const (Const.UInt32 (opUInt32 x1 x2), m, ty)
|
||||
| Expr.Const (Const.UInt64 x1, _, ty), Expr.Const (Const.UInt64 x2, _, _) -> Expr.Const (Const.UInt64 (opUInt64 x1 x2), m, ty)
|
||||
| Expr.Const (Const.Single x1, _, ty), Expr.Const (Const.Single x2, _, _) -> Expr.Const (Const.Single (opSingle x1 x2), m, ty)
|
||||
| Expr.Const (Const.Double x1, _, ty), Expr.Const (Const.Double x2, _, _) -> Expr.Const (Const.Double (opDouble x1 x2), m, ty)
|
||||
| _ -> error (Error ( FSComp.SR.tastNotAConstantExpression(), m))
|
||||
with :? System.OverflowException -> error (Error ( FSComp.SR.tastConstantExpressionOverflow(), m))
|
||||
|
||||
// See also PostTypeCheckSemanticChecks.CheckAttribArgExpr, which must match this precisely
|
||||
let rec EvalAttribArgExpr g x =
|
||||
let rec EvalAttribArgExpr (g: TcGlobals) x =
|
||||
let ignore (_x: 'a) = Unchecked.defaultof<'a>
|
||||
let ignore2 (_x: 'a) (_y: 'a) = Unchecked.defaultof<'a>
|
||||
|
||||
let arithmeticInLiteralsEnabled = g.langVersion.SupportsFeature LanguageFeature.ArithmeticInLiterals
|
||||
|
||||
match x with
|
||||
|
||||
// Detect standard constants
|
||||
|
@ -9699,30 +9762,93 @@ let rec EvalAttribArgExpr g x =
|
|||
EvalAttribArgExpr g arg1
|
||||
// Detect bitwise or of attribute flags
|
||||
| AttribBitwiseOrExpr g (arg1, arg2) ->
|
||||
EvalArithBinOp ((|||), (|||), (|||), (|||), (|||), (|||), (|||), (|||)) (EvalAttribArgExpr g arg1) (EvalAttribArgExpr g arg2)
|
||||
| SpecificBinopExpr g g.unchecked_addition_vref (arg1, arg2) ->
|
||||
// At compile-time we check arithmetic
|
||||
let v1, v2 = EvalAttribArgExpr g arg1, EvalAttribArgExpr g arg2
|
||||
match v1, v2 with
|
||||
| Expr.Const (Const.String x1, m, ty), Expr.Const (Const.String x2, _, _) -> Expr.Const (Const.String (x1 + x2), m, ty)
|
||||
| _ ->
|
||||
#if ALLOW_ARITHMETIC_OPS_IN_LITERAL_EXPRESSIONS_AND_ATTRIBUTE_ARGS
|
||||
EvalArithBinOp (Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+)) g v1 v2
|
||||
#else
|
||||
errorR (Error ( FSComp.SR.tastNotAConstantExpression(), x.Range))
|
||||
x
|
||||
#endif
|
||||
#if ALLOW_ARITHMETIC_OPS_IN_LITERAL_EXPRESSIONS_AND_ATTRIBUTE_ARGS
|
||||
| SpecificBinopExpr g g.unchecked_subtraction_vref (arg1, arg2) ->
|
||||
EvalArithBinOp (Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-)) g (EvalAttribArgExpr g arg1) (EvalAttribArgExpr g arg2)
|
||||
| SpecificBinopExpr g g.unchecked_multiply_vref (arg1, arg2) ->
|
||||
EvalArithBinOp (Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*)) g (EvalAttribArgExpr g arg1) (EvalAttribArgExpr g arg2)
|
||||
#endif
|
||||
let v1 = EvalAttribArgExpr g arg1
|
||||
|
||||
match v1 with
|
||||
| IntegerConstExpr ->
|
||||
EvalArithBinOp ((|||), (|||), (|||), (|||), (|||), (|||), (|||), (|||), ignore2, ignore2) v1 (EvalAttribArgExpr g arg2)
|
||||
| _ ->
|
||||
errorR (Error ( FSComp.SR.tastNotAConstantExpression(), x.Range))
|
||||
x
|
||||
| SpecificBinopExpr g g.unchecked_addition_vref (arg1, arg2) ->
|
||||
// At compile-time we check arithmetic
|
||||
let v1, v2 = EvalAttribArgExpr g arg1, EvalAttribArgExpr g arg2
|
||||
match v1, v2 with
|
||||
| Expr.Const (Const.String x1, m, ty), Expr.Const (Const.String x2, _, _) ->
|
||||
Expr.Const (Const.String (x1 + x2), m, ty)
|
||||
| Expr.Const (Const.Char x1, m, ty), Expr.Const (Const.Char x2, _, _) when arithmeticInLiteralsEnabled ->
|
||||
Expr.Const (Const.Char (x1 + x2), m, ty)
|
||||
| _ ->
|
||||
if arithmeticInLiteralsEnabled then
|
||||
EvalArithBinOp (Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+), Checked.(+)) v1 v2
|
||||
else
|
||||
errorR (Error ( FSComp.SR.tastNotAConstantExpression(), x.Range))
|
||||
x
|
||||
| SpecificBinopExpr g g.unchecked_subtraction_vref (arg1, arg2) when arithmeticInLiteralsEnabled ->
|
||||
let v1, v2 = EvalAttribArgExpr g arg1, EvalAttribArgExpr g arg2
|
||||
match v1, v2 with
|
||||
| Expr.Const (Const.Char x1, m, ty), Expr.Const (Const.Char x2, _, _) ->
|
||||
Expr.Const (Const.Char (x1 - x2), m, ty)
|
||||
| _ ->
|
||||
EvalArithBinOp (Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-), Checked.(-)) v1 v2
|
||||
| SpecificBinopExpr g g.unchecked_multiply_vref (arg1, arg2) when arithmeticInLiteralsEnabled ->
|
||||
EvalArithBinOp (Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*), Checked.(*)) (EvalAttribArgExpr g arg1) (EvalAttribArgExpr g arg2)
|
||||
| SpecificBinopExpr g g.unchecked_division_vref (arg1, arg2) when arithmeticInLiteralsEnabled ->
|
||||
EvalArithBinOp ((/), (/), (/), (/), (/), (/), (/), (/), (/), (/)) (EvalAttribArgExpr g arg1) (EvalAttribArgExpr g arg2)
|
||||
| SpecificBinopExpr g g.unchecked_modulus_vref (arg1, arg2) when arithmeticInLiteralsEnabled ->
|
||||
EvalArithBinOp ((%), (%), (%), (%), (%), (%), (%), (%), (%), (%)) (EvalAttribArgExpr g arg1) (EvalAttribArgExpr g arg2)
|
||||
| SpecificBinopExpr g g.bitwise_shift_left_vref (arg1, arg2) when arithmeticInLiteralsEnabled ->
|
||||
EvalArithShiftOp ((<<<), (<<<), (<<<), (<<<), (<<<), (<<<), (<<<), (<<<)) (EvalAttribArgExpr g arg1) (EvalAttribArgExpr g arg2)
|
||||
| SpecificBinopExpr g g.bitwise_shift_right_vref (arg1, arg2) when arithmeticInLiteralsEnabled ->
|
||||
EvalArithShiftOp ((>>>), (>>>), (>>>), (>>>), (>>>), (>>>), (>>>), (>>>)) (EvalAttribArgExpr g arg1) (EvalAttribArgExpr g arg2)
|
||||
| SpecificBinopExpr g g.bitwise_and_vref (arg1, arg2) when arithmeticInLiteralsEnabled ->
|
||||
let v1 = EvalAttribArgExpr g arg1
|
||||
|
||||
match v1 with
|
||||
| IntegerConstExpr ->
|
||||
EvalArithBinOp ((&&&), (&&&), (&&&), (&&&), (&&&), (&&&), (&&&), (&&&), ignore2, ignore2) v1 (EvalAttribArgExpr g arg2)
|
||||
| _ ->
|
||||
errorR (Error ( FSComp.SR.tastNotAConstantExpression(), x.Range))
|
||||
x
|
||||
| SpecificUnopExpr g g.unchecked_unary_minus_vref arg1 when arithmeticInLiteralsEnabled ->
|
||||
let v1 = EvalAttribArgExpr g arg1
|
||||
|
||||
match v1 with
|
||||
| SignedConstExpr ->
|
||||
EvalArithUnOp (Checked.(~-), Checked.(~-), Checked.(~-), Checked.(~-), ignore, ignore, ignore, ignore, Checked.(~-), Checked.(~-)) v1
|
||||
| _ ->
|
||||
errorR (Error ( FSComp.SR.tastNotAConstantExpression(), v1.Range))
|
||||
x
|
||||
| SpecificUnopExpr g g.unchecked_unary_plus_vref arg1 when arithmeticInLiteralsEnabled ->
|
||||
EvalArithUnOp ((~+), (~+), (~+), (~+), (~+), (~+), (~+), (~+), (~+), (~+)) (EvalAttribArgExpr g arg1)
|
||||
| SpecificUnopExpr g g.unchecked_unary_not_vref arg1 when arithmeticInLiteralsEnabled ->
|
||||
match EvalAttribArgExpr g arg1 with
|
||||
| Expr.Const (Const.Bool value, m, ty) ->
|
||||
Expr.Const (Const.Bool (not value), m, ty)
|
||||
| expr ->
|
||||
errorR (Error ( FSComp.SR.tastNotAConstantExpression(), expr.Range))
|
||||
x
|
||||
// Detect logical operations on booleans, which are represented as a match expression
|
||||
| Expr.Match (decision = TDSwitch (input = input; cases = [ TCase (DecisionTreeTest.Const (Const.Bool test), TDSuccess ([], targetNum)) ]); targets = [| TTarget (_, t0, _); TTarget (_, t1, _) |]) when arithmeticInLiteralsEnabled ->
|
||||
match EvalAttribArgExpr g (stripDebugPoints input) with
|
||||
| Expr.Const (Const.Bool value, _, _) ->
|
||||
let pass, fail =
|
||||
if targetNum = 0 then
|
||||
t0, t1
|
||||
else
|
||||
t1, t0
|
||||
|
||||
if value = test then
|
||||
EvalAttribArgExpr g (stripDebugPoints pass)
|
||||
else
|
||||
EvalAttribArgExpr g (stripDebugPoints fail)
|
||||
| _ ->
|
||||
errorR (Error ( FSComp.SR.tastNotAConstantExpression(), x.Range))
|
||||
x
|
||||
| _ ->
|
||||
errorR (Error ( FSComp.SR.tastNotAConstantExpression(), x.Range))
|
||||
x
|
||||
|
||||
|
||||
and EvaledAttribExprEquality g e1 e2 =
|
||||
match e1, e2 with
|
||||
| Expr.Const (c1, _, _), Expr.Const (c2, _, _) -> c1 = c2
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">aplikativní výpočetní výrazy</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">atributy napravo od klíčového slova Module</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">Neplatné použití generování referenčního sestavení, nepoužívejte --staticlink ani --refonly a --refout společně.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">applikative Berechnungsausdrücke</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">Attribute rechts vom "Module"-Schlüsselwort</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">Ungültige Verwendung der Ausgabe einer Referenzassembly. Verwenden Sie nicht "--staticlink" oder "--refonly" und "--refout" zusammen.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">expresiones de cálculo aplicativas</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">atributos a la derecha de la palabra clave “módulo”</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">Uso no válido de emitir un ensamblado de referencia, no use "--staticlink', or '--refonly' and '--refout" de forma conjunta.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">expressions de calcul applicatives</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">attributs à droite du mot clé 'module'</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">Utilisation non valide de l’émission d’un assembly de référence. N’utilisez pas '--staticlink' ni '--refonly' et '--refout' ensemble.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">espressioni di calcolo applicativo</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">attributi a destra della parola chiave 'module'</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">Utilizzo non valido della creazione di un assembly di riferimento. Non usare insieme '--staticlink' o '--refonly' e '--refout'.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">適用できる計算式</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">'module' キーワードの右側の属性</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">参照アセンブリの生成の使用が無効です。'--staticlink'、または '--refonly' と '--refout' を同時に使用しないでください。</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">적용 가능한 계산 식</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">'module' 키워드 오른쪽에 있는 특성</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">참조 어셈블리 내보내기를 잘못 사용했습니다. '--staticlink' 또는 '--refonly' 및 '--refout'을 함께 사용하지 마세요.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">praktyczne wyrażenia obliczeniowe</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">atrybuty po prawej stronie słowa kluczowego "module"</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">Nieprawidłowe użycie emitowania zestawu odwołania, nie używaj razem elementów „--staticlink” ani „--refonly” i „--refout”.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">expressões de computação aplicáveis</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">atributos à direita da palavra-chave 'módulo'</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">Uso inválido de emitir um assembly de referência, não use '--staticlink' ou '--reutilly' e '--refout' juntos.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">применимые вычислительные выражения</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">атрибуты справа от ключевого слова "module"</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">Недопустимое использование при создании базовой сборки. Не используйте "--staticlink" или "--refonly" и "--refout" вместе.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">uygulama hesaplama ifadeleri</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">'modül' anahtar sözcüğünün sağındaki öznitelikler</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">Başvuru bütünleştirilmiş kodunun oluşturulması için geçersiz kullanım: '--staticlink' veya '--refonly' ile '--refout' birlikte kullanılmaz.</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">适用的计算表达式</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">"module" 关键字右侧的属性</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">发出引用程序集的使用无效,请勿同时使用“--staticlink”或“--refonly”和“--refout”。</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -142,6 +142,11 @@
|
|||
<target state="translated">適用的計算運算式</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureArithmeticInLiterals">
|
||||
<source>Allow arithmetic and logical operations in literals</source>
|
||||
<target state="new">Allow arithmetic and logical operations in literals</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="featureAttributesToRightOfModuleKeyword">
|
||||
<source>attributes to the right of the 'module' keyword</source>
|
||||
<target state="translated">'module' 關鍵字右邊的屬性</target>
|
||||
|
@ -538,8 +543,8 @@
|
|||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefAssembly">
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.</source>
|
||||
<target state="translated">發出參考組件的使用無效,請勿同時使用 '--staticlink' 或 '--refonly' 和 '--refout'。</target>
|
||||
<source>Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</source>
|
||||
<target state="new">Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.</target>
|
||||
<note />
|
||||
</trans-unit>
|
||||
<trans-unit id="optsInvalidRefOut">
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.Core/FSharp.Core.fsproj" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.Core/FSharp.Core.fsproj" AdditionalProperties="TargetFramework=netstandard2.0" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.Build/FSharp.Build.fsproj" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)../Compiler/FSharp.Compiler.Service.fsproj" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)../FSharp.DependencyManager.Nuget/FSharp.DependencyManager.Nuget.fsproj" />
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\FSharp.Core\FSharp.Core.fsproj" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\FSharp.Core\FSharp.Core.fsproj" AdditionalProperties="TargetFramework=netstandard2.0" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\Compiler\FSharp.Compiler.Service.fsproj" />
|
||||
<ProjectReference Include="$(MSBuildThisFileDirectory)..\FSharp.Compiler.Interactive.Settings\FSharp.Compiler.Interactive.Settings.fsproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
<DefineConstants>NO_GENERATIVE</DefineConstants>
|
||||
<DefineConstants>IS_DESIGNTIME</DefineConstants>
|
||||
<FSharpCoreImplicitPackageVersion>$(FSharpCoreShippedPackageVersionValue)</FSharpCoreImplicitPackageVersion>
|
||||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
<IsPackable>false</IsPackable>
|
||||
<DefineConstants>NO_GENERATIVE</DefineConstants>
|
||||
<FSharpCoreImplicitPackageVersion>$(FSharpCoreShippedPackageVersionValue)</FSharpCoreImplicitPackageVersion>
|
||||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
<FSharpCoreImplicitPackageVersion>$(FSharpCoreShippedPackageVersionValue)</FSharpCoreImplicitPackageVersion>
|
||||
<PackagePath>typeproviders</PackagePath>
|
||||
<NoWarn>$(NoWarn);NU5100;NU5118</NoWarn>
|
||||
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
|
||||
|
||||
namespace FSharp.Compiler.ComponentTests.CompilerOptions
|
||||
|
||||
open Xunit
|
||||
open FSharp.Test
|
||||
open FSharp.Test.Compiler
|
||||
|
||||
module RefOnlyRefOut =
|
||||
|
||||
// Test refout/refonly alongside standalone
|
||||
[<Fact>]
|
||||
let ``fsc --refonly --standalone``() =
|
||||
FSharp """
|
||||
"""
|
||||
|> asExe
|
||||
|> withOptions ["--refonly"; "--standalone"]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withDiagnostics [
|
||||
(Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.")
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``fsc --standalone --refonly ``() =
|
||||
FSharp """
|
||||
"""
|
||||
|> asExe
|
||||
|> withOptions ["--standalone"; "--refonly"]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withDiagnostics [
|
||||
(Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.")
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``fsc --refout:. --standalone``() =
|
||||
FSharp """
|
||||
"""
|
||||
|> asExe
|
||||
|> withOptions ["--refout:."; "--standalone"]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withDiagnostics [
|
||||
(Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.")
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``fsc --standalone --refout:.``() =
|
||||
FSharp """
|
||||
"""
|
||||
|> asExe
|
||||
|> withOptions ["--standalone"; "--refout:."]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withDiagnostics [
|
||||
(Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.")
|
||||
]
|
||||
|
||||
// Test refout/refonly alongside staticlink
|
||||
[<Fact>]
|
||||
let ``fsc --refonly --staticlink:.``() =
|
||||
FSharp """
|
||||
"""
|
||||
|> asExe
|
||||
|> withOptions ["--refonly"; "--staticlink:."]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withDiagnostics [
|
||||
(Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.")
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``fsc --staticlink:. --refonly ``() =
|
||||
FSharp """
|
||||
"""
|
||||
|> asExe
|
||||
|> withOptions ["--staticlink:."; "--refonly"]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withDiagnostics [
|
||||
(Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.")
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``fsc --refout:. --staticlink:.``() =
|
||||
FSharp """
|
||||
"""
|
||||
|> asExe
|
||||
|> withOptions ["--refout:."; "--staticlink:."]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withDiagnostics [
|
||||
(Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.")
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``fsc --staticlink:. --refout:.``() =
|
||||
FSharp """
|
||||
"""
|
||||
|> asExe
|
||||
|> withOptions ["--staticlink:."; "--refout:."]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withDiagnostics [
|
||||
(Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--standalone or --staticlink' with '--refonly or --refout'.")
|
||||
]
|
|
@ -127,17 +127,6 @@ module AttributeUsage =
|
|||
(Error 685, Line 20, Col 5, Line 20, Col 10, "The generic function 'Foo' must be given explicit type argument(s)")
|
||||
]
|
||||
|
||||
// # SOURCE=E_WithBitwiseAnd01.fsx SCFLAGS="--test:ErrorRanges -a" # E_WithBitwiseAnd01.fsx
|
||||
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_WithBitwiseAnd01.fsx"|])>]
|
||||
let ``E_WithBitwiseAnd01_fsx`` compilation =
|
||||
compilation
|
||||
|> verifyCompile
|
||||
|> shouldFail
|
||||
|> withDiagnostics [
|
||||
(Error 267, Line 7, Col 25, Line 7, Col 91, "This is not a valid constant expression or custom attribute value")
|
||||
(Warning 839, Line 12, Col 3, Line 12, Col 6, "Unexpected condition in imported assembly: failed to decode AttributeUsage attribute")
|
||||
]
|
||||
|
||||
// SOURCE=E_WithBitwiseOr01.fsx SCFLAGS="--test:ErrorRanges -a" # E_WithBitwiseOr01.fsx
|
||||
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_WithBitwiseOr01.fsx"|])>]
|
||||
let ``E_WithBitwiseOr01_fsx`` compilation =
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
// #Regression #Conformance #DeclarationElements #Attributes
|
||||
// Regression test for FSHARP1.0:4035
|
||||
// Using bitwise AND (&&&) in AttributeUsage should give a reasonable error
|
||||
//<Expects id="FS0191" status="error">Review when fixed</Expects>
|
||||
#light
|
||||
|
||||
[<System.AttributeUsage(System.AttributeTargets.Class &&& System.AttributeTargets.Assembly, AllowMultiple=true)>]
|
||||
[<Sealed>]
|
||||
type FooAttribute() =
|
||||
inherit System.Attribute()
|
||||
|
||||
[<Foo>]
|
||||
let x = 1
|
|
@ -24,3 +24,207 @@ let main _ =
|
|||
|> verifyIL ["""
|
||||
.field public static literal int32 x = int32(0x00000007)
|
||||
.custom instance void [FSharp.Core]Microsoft.FSharp.Core.LiteralAttribute::.ctor() = ( 01 00 00 00 )"""]
|
||||
|
||||
|
||||
[<Fact>]
|
||||
let ``Arithmetic in integer literals is evaluated at compile time``() =
|
||||
FSharp """
|
||||
module LiteralArithmetic
|
||||
|
||||
let [<Literal>] bytesInMegabyte = 1024L * 1024L
|
||||
|
||||
let [<Literal>] bytesInKilobyte = bytesInMegabyte >>> 10
|
||||
|
||||
let [<Literal>] bytesInKilobyte2 = bytesInMegabyte / 1024L
|
||||
|
||||
let [<Literal>] secondsInDayPlusThree = 3 + (60 * 60 * 24)
|
||||
|
||||
let [<Literal>] bitwise = 1us &&& (3us ||| 4us)
|
||||
"""
|
||||
|> withLangVersionPreview
|
||||
|> compile
|
||||
|> shouldSucceed
|
||||
|> verifyIL [
|
||||
""".field public static literal int64 bytesInMegabyte = int64(0x100000)"""
|
||||
""".field public static literal int64 bytesInKilobyte = int64(0x400)"""
|
||||
""".field public static literal int64 bytesInKilobyte2 = int64(0x400)"""
|
||||
""".field public static literal int32 secondsInDayPlusThree = int32(0x00015183)"""
|
||||
""".field public static literal uint16 bitwise = uint16(0x0001)"""
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``Arithmetic in char and floating point literals is evaluated at compile time``() =
|
||||
// on Linux and Mac floats with no decimal parts are printed without the decimal point (unlike Windows)
|
||||
// let's add some fractions so that the tests are consistent
|
||||
FSharp """
|
||||
module LiteralArithmetic
|
||||
|
||||
let [<Literal>] bytesInMegabyte = 1024. * 1024. + 0.1
|
||||
|
||||
let [<Literal>] bytesInKilobyte = bytesInMegabyte / 1024. + 0.1
|
||||
|
||||
let [<Literal>] secondsInDayPlusThree = 3.1f + (60f * 60f * 24f)
|
||||
|
||||
let [<Literal>] chars = 'a' + 'b' - 'a'
|
||||
"""
|
||||
|> withLangVersionPreview
|
||||
|> compile
|
||||
|> shouldSucceed
|
||||
|> verifyIL [
|
||||
""".field public static literal float64 bytesInMegabyte = float64(1048576.1000000001)"""
|
||||
""".field public static literal float64 bytesInKilobyte = float64(1024.10009765625)"""
|
||||
""".field public static literal float32 secondsInDayPlusThree = float32(86403.102)"""
|
||||
""".field public static literal char chars = char(0x0062)"""
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``Logical operations on booleans are evaluated at compile time``() =
|
||||
FSharp """
|
||||
module LiteralArithmetic
|
||||
|
||||
let [<Literal>] flag = true
|
||||
|
||||
let [<Literal>] flippedFlag = not flag
|
||||
|
||||
let [<Literal>] simple1 = flippedFlag || false
|
||||
|
||||
let [<Literal>] simple2 = true && not true
|
||||
|
||||
let [<Literal>] complex1 = false || (flag && not flippedFlag)
|
||||
|
||||
let [<Literal>] complex2 = false || (flag && flippedFlag)
|
||||
|
||||
let [<Literal>] complex3 = true || (flag && not flippedFlag)
|
||||
"""
|
||||
|> withLangVersionPreview
|
||||
|> compile
|
||||
|> shouldSucceed
|
||||
|> verifyIL [
|
||||
""".field public static literal bool flag = bool(true)"""
|
||||
""".field public static literal bool flippedFlag = bool(false)"""
|
||||
""".field public static literal bool simple1 = bool(false)"""
|
||||
""".field public static literal bool simple2 = bool(false)"""
|
||||
""".field public static literal bool complex1 = bool(true)"""
|
||||
""".field public static literal bool complex2 = bool(false)"""
|
||||
""".field public static literal bool complex3 = bool(true)"""
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``Arithmetic can be used for constructing enum literals``() =
|
||||
FSharp """
|
||||
module LiteralArithmetic
|
||||
|
||||
type E =
|
||||
| A = 1
|
||||
| B = 2
|
||||
|
||||
let [<Literal>] x = enum<E> (1 + 1)
|
||||
"""
|
||||
|> withLangVersionPreview
|
||||
|> compile
|
||||
|> shouldSucceed
|
||||
|> verifyIL [
|
||||
""".field public static literal valuetype LiteralArithmetic/E x = int32(0x00000002)"""
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``Arithmetic can be used for constructing literals in attributes``() =
|
||||
FSharp """
|
||||
module LiteralArithmetic
|
||||
|
||||
open System.Runtime.CompilerServices
|
||||
|
||||
// 256 = AggressiveInlining
|
||||
[<MethodImpl(enum -(-1 <<< 8))>]
|
||||
let x () =
|
||||
3
|
||||
"""
|
||||
|> withLangVersionPreview
|
||||
|> compile
|
||||
|> shouldSucceed
|
||||
|> verifyIL [
|
||||
""".method public static int32 x() cil managed aggressiveinlining"""
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``Compilation fails when addition in literal overflows``() =
|
||||
FSharp """
|
||||
module LiteralArithmetic
|
||||
|
||||
let [<Literal>] x = System.Int32.MaxValue + 1
|
||||
"""
|
||||
|> withLangVersionPreview
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withResult {
|
||||
Error = Error 3177
|
||||
Range = { StartLine = 4
|
||||
StartColumn = 21
|
||||
EndLine = 4
|
||||
EndColumn = 46 }
|
||||
Message = "This literal expression or attribute argument results in an arithmetic overflow."
|
||||
}
|
||||
|
||||
[<Fact>]
|
||||
let ``Compilation fails when using decimal arithmetic in literal``() =
|
||||
FSharp """
|
||||
module LiteralArithmetic
|
||||
|
||||
let [<Literal>] x = 1m + 1m
|
||||
"""
|
||||
|> withLangVersionPreview
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withResults [
|
||||
{ Error = Error 267
|
||||
Range = { StartLine = 4
|
||||
StartColumn = 21
|
||||
EndLine = 4
|
||||
EndColumn = 23 }
|
||||
Message = "This is not a valid constant expression or custom attribute value" }
|
||||
{ Error = Error 267
|
||||
Range = { StartLine = 4
|
||||
StartColumn = 26
|
||||
EndLine = 4
|
||||
EndColumn = 28 }
|
||||
Message = "This is not a valid constant expression or custom attribute value" }
|
||||
{ Error = Error 267
|
||||
Range = { StartLine = 4
|
||||
StartColumn = 21
|
||||
EndLine = 4
|
||||
EndColumn = 28 }
|
||||
Message = "This is not a valid constant expression or custom attribute value" }
|
||||
]
|
||||
|
||||
[<Fact>]
|
||||
let ``Compilation fails when using arithmetic with a non-literal in literal``() =
|
||||
FSharp """
|
||||
module LiteralArithmetic
|
||||
|
||||
let [<Literal>] x = 1 + System.DateTime.Now.Hour
|
||||
"""
|
||||
|> withLangVersionPreview
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withResults [
|
||||
#if !NETCOREAPP
|
||||
{ Error = Warning 52
|
||||
Range = { StartLine = 4
|
||||
StartColumn = 25
|
||||
EndLine = 4
|
||||
EndColumn = 49 }
|
||||
Message = "The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed" }
|
||||
#endif
|
||||
{ Error = Error 267
|
||||
Range = { StartLine = 4
|
||||
StartColumn = 25
|
||||
EndLine = 4
|
||||
EndColumn = 49 }
|
||||
Message = "This is not a valid constant expression or custom attribute value" }
|
||||
{ Error = Error 267
|
||||
Range = { StartLine = 4
|
||||
StartColumn = 21
|
||||
EndLine = 4
|
||||
EndColumn = 49 }
|
||||
Message = "This is not a valid constant expression or custom attribute value" }
|
||||
]
|
|
@ -178,6 +178,7 @@
|
|||
<Compile Include="Language\ExtensionMethodTests.fs" />
|
||||
<Compile Include="ConstraintSolver\PrimitiveConstraints.fs" />
|
||||
<Compile Include="ConstraintSolver\MemberConstraints.fs" />
|
||||
<Compile Include="Interop\DeeplyNestedCSharpClasses.fs" />
|
||||
<Compile Include="Interop\SimpleInteropTests.fs" />
|
||||
<Compile Include="Interop\RequiredAndInitOnlyProperties.fs" />
|
||||
<Compile Include="Interop\StaticsInInterfaces.fs" />
|
||||
|
@ -196,6 +197,7 @@
|
|||
<Compile Include="CompilerOptions\fsc\warnon\warnon.fs" />
|
||||
<Compile Include="CompilerOptions\fsc\reference.fs" />
|
||||
<Compile Include="CompilerOptions\fsc\reflectionfree.fs" />
|
||||
<Compile Include="CompilerOptions\fsc\refonlyrefout.fs" />
|
||||
<Compile Include="Debugger\PortablePdbs.fs" />
|
||||
<Compile Include="Diagnostics\async.fs" />
|
||||
<Compile Include="Diagnostics\General.fs" />
|
||||
|
@ -213,6 +215,9 @@
|
|||
<Compile Include="FSharpChecker\CommonWorkflows.fs" />
|
||||
<Compile Include="FSharpChecker\SymbolUse.fs" />
|
||||
<Compile Include="FSharpChecker\FindReferences.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="**\*.cs;**\*.fs;**\*.fsx;**\*.fsi" Exclude="@(Compile)">
|
||||
<Link>%(RelativeDir)\TestSource\%(Filename)%(Extension)</Link>
|
||||
</None>
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
|
||||
namespace FSharp.Compiler.ComponentTests.Interop
|
||||
|
||||
open Xunit
|
||||
open FSharp.Test.Compiler
|
||||
open FSharp.Test
|
||||
open System
|
||||
|
||||
module ``Deeply nested CSharpClasses`` =
|
||||
|
||||
let cslib =
|
||||
CSharp """
|
||||
using System;
|
||||
|
||||
namespace MyNamespace
|
||||
{
|
||||
public class OuterClass
|
||||
{
|
||||
|
||||
public class InnerClass
|
||||
{
|
||||
|
||||
public class MoreInnerClass
|
||||
{
|
||||
public static void somefunction() { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}"""
|
||||
|
||||
[<Fact>]
|
||||
let ``Missing type outerclass generates good message and range`` () =
|
||||
|
||||
let fsharpSource =
|
||||
"""
|
||||
let loss2 = MyNamespace.OoterClass.InnerClass.MoreInnerClass.somefunction() //Note the miss-typed functionname we expect a good error message
|
||||
"""
|
||||
FSharp fsharpSource
|
||||
|> asExe
|
||||
|> withReferences [cslib]
|
||||
|> compile
|
||||
|> withSingleDiagnostic (Error 39, Line 2, Col 25, Line 2, Col 35, "The value, constructor, namespace or type 'OoterClass' is not defined. Maybe you want one of the following:
|
||||
OuterClass")
|
||||
|
||||
[<Fact>]
|
||||
let ``Missing type nested type innerclass generates good message and range`` () =
|
||||
|
||||
let fsharpSource =
|
||||
"""
|
||||
let loss2 = MyNamespace.OuterClass.InerClass.MoreInnerClass.somefunction() //Note the miss-typed InnerClass name we expect a good error message
|
||||
"""
|
||||
FSharp fsharpSource
|
||||
|> asExe
|
||||
|> withReferences [cslib]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withSingleDiagnostic (Error 39, Line 2, Col 36, Line 2, Col 45, "The type 'OuterClass' does not define the field, constructor or member 'InerClass'.")
|
||||
|
||||
[<Fact>]
|
||||
let ``Missing type nested type moreinnerclass generates good message and range`` () =
|
||||
|
||||
let fsharpSource =
|
||||
"""
|
||||
let loss2 = MyNamespace.OuterClass.InnerClass.MoareInnerClass.somefunction() //Note the miss-typed MoreInnerClass we expect a good error message
|
||||
"""
|
||||
FSharp fsharpSource
|
||||
|> asExe
|
||||
|> withReferences [cslib]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withSingleDiagnostic (Error 39, Line 2, Col 47, Line 2, Col 62, "The type 'InnerClass' does not define the field, constructor or member 'MoareInnerClass'.")
|
||||
|
||||
[<Fact>]
|
||||
let ``Missing function generates good message and range`` () =
|
||||
|
||||
let fsharpSource =
|
||||
"""
|
||||
let loss2 = MyNamespace.OuterClass.InnerClass.MoreInnerClass.somefunctoion() //Note the miss-typed somefunction we expect a good error message
|
||||
"""
|
||||
FSharp fsharpSource
|
||||
|> asExe
|
||||
|> withReferences [cslib]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withSingleDiagnostic ((Error 39, Line 2, Col 62, Line 2, Col 75, """The type 'MoreInnerClass' does not define the field, constructor or member 'somefunctoion'. Maybe you want one of the following:
|
||||
somefunction"""))
|
|
@ -30,4 +30,10 @@ let b: System.IComparable = $"string"
|
|||
let c: System.IFormattable = $"string"
|
||||
"""
|
||||
|> compile
|
||||
|> shouldSucceed
|
||||
|> shouldSucceed
|
||||
|
||||
[<Fact>]
|
||||
let ``Percent sign characters in interpolated strings`` () =
|
||||
Assert.Equal("%", $"%%")
|
||||
Assert.Equal("42%", $"{42}%%")
|
||||
Assert.Equal("% 42", $"%%%3d{42}")
|
|
@ -393,44 +393,6 @@ let test() =
|
|||
}"""
|
||||
]
|
||||
|
||||
[<Test>]
|
||||
let ``Can't use both --refonly and --staticlink``() =
|
||||
let src =
|
||||
"""
|
||||
module ReferenceAssembly
|
||||
|
||||
open System
|
||||
|
||||
let test() =
|
||||
Console.WriteLine("Hello World!")
|
||||
"""
|
||||
|
||||
FSharp src
|
||||
|> withOptions ["--staticlink:foo"; "--refonly"]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withSingleDiagnostic (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.")
|
||||
|> ignore
|
||||
|
||||
[<Test>]
|
||||
let ``Can't use both --refoout and --staticlink``() =
|
||||
let src =
|
||||
"""
|
||||
module ReferenceAssembly
|
||||
|
||||
open System
|
||||
|
||||
let test() =
|
||||
Console.WriteLine("Hello World!")
|
||||
"""
|
||||
|
||||
FSharp src
|
||||
|> withOptions ["--staticlink:foo"; "--refout:foo"]
|
||||
|> compile
|
||||
|> shouldFail
|
||||
|> withSingleDiagnostic (Error 2030, Line 0, Col 1, Line 0, Col 1, "Invalid use of emitting a reference assembly, do not use '--staticlink', or '--refonly' and '--refout' together.")
|
||||
|> ignore
|
||||
|
||||
[<Test>]
|
||||
let ``Internal DU type doesn't generate any properties/methods without IVT`` () =
|
||||
FSharp """
|
||||
|
|
|
@ -30,6 +30,27 @@ module InlineParameterNameHints =
|
|||
let private doesFieldNameExist (field: FSharpField) =
|
||||
not field.IsNameGenerated
|
||||
|
||||
let private getTupleRanges
|
||||
(symbolUse: FSharpSymbolUse)
|
||||
(parseResults: FSharpParseFileResults) =
|
||||
|
||||
let position = Position.mkPos
|
||||
(symbolUse.Range.End.Line)
|
||||
(symbolUse.Range.End.Column + 1)
|
||||
|
||||
parseResults.FindParameterLocations position
|
||||
|> Option.map (fun locations -> locations.ArgumentLocations)
|
||||
|> Option.map (Seq.map (fun location -> location.ArgumentRange))
|
||||
|> Option.defaultValue []
|
||||
|> Seq.toList
|
||||
|
||||
let private getCurryRanges
|
||||
(symbolUse: FSharpSymbolUse)
|
||||
(parseResults: FSharpParseFileResults) =
|
||||
|
||||
parseResults.GetAllArgumentsForFunctionApplicationAtPosition symbolUse.Range.Start
|
||||
|> Option.defaultValue []
|
||||
|
||||
let isMemberOrFunctionOrValueValidForHint (symbol: FSharpMemberOrFunctionOrValue) (symbolUse: FSharpSymbolUse) =
|
||||
if symbolUse.IsFromUse then
|
||||
let isNotBuiltInOperator =
|
||||
|
@ -52,18 +73,16 @@ module InlineParameterNameHints =
|
|||
(symbolUse: FSharpSymbolUse) =
|
||||
|
||||
let parameters = symbol.CurriedParameterGroups |> Seq.concat
|
||||
let ranges = parseResults.GetAllArgumentsForFunctionApplicationAtPosition symbolUse.Range.Start
|
||||
|
||||
match ranges with
|
||||
| Some ranges ->
|
||||
parameters
|
||||
|> Seq.zip ranges
|
||||
|> Seq.where (snd >> doesParameterNameExist)
|
||||
|> Seq.map getParameterHint
|
||||
|> Seq.toList
|
||||
|
||||
// this is the case at least for custom operators
|
||||
| None -> []
|
||||
let tupleRanges = parseResults |> getTupleRanges symbolUse
|
||||
let curryRanges = parseResults |> getCurryRanges symbolUse
|
||||
let ranges = if tupleRanges |> (not << Seq.isEmpty) then tupleRanges else curryRanges
|
||||
|
||||
parameters
|
||||
|> Seq.zip ranges // Seq.zip is important as List.zip requires equal lengths
|
||||
|> Seq.where (snd >> doesParameterNameExist)
|
||||
|> Seq.map getParameterHint
|
||||
|> Seq.toList
|
||||
|
||||
let getHintsForUnionCase
|
||||
(parseResults: FSharpParseFileResults)
|
||||
|
|
|
@ -32,7 +32,9 @@ module HintTestFramework =
|
|||
let getFsDocument code =
|
||||
use project = SingleFileProject code
|
||||
let fileName = fst project.Files.Head
|
||||
let document, _ = RoslynTestHelpers.CreateSingleDocumentSolution(fileName, code)
|
||||
// I don't know, without this lib some symbols are just not loaded
|
||||
let options = { project.Options with OtherOptions = [| "--targetprofile:netcore" |] }
|
||||
let document, _ = RoslynTestHelpers.CreateSingleDocumentSolution(fileName, code, options)
|
||||
document
|
||||
|
||||
let getFsiAndFsDocuments (fsiCode: string) (fsCode: string) =
|
||||
|
|
|
@ -381,3 +381,28 @@ type X =
|
|||
let actual = getParameterNameHints document
|
||||
|
||||
Assert.IsEmpty(actual)
|
||||
|
||||
[<Test>]
|
||||
let ``Hints are not shown in front of indexes`` () =
|
||||
let code =
|
||||
"""
|
||||
let x = "test".Split("").[0].Split("");
|
||||
"""
|
||||
|
||||
let document = getFsDocument code
|
||||
|
||||
let expected =
|
||||
[
|
||||
{
|
||||
Content = "separator = "
|
||||
Location = (1, 22)
|
||||
}
|
||||
{
|
||||
Content = "separator = "
|
||||
Location = (1, 36)
|
||||
}
|
||||
]
|
||||
|
||||
let actual = getParameterNameHints document
|
||||
|
||||
Assert.AreEqual(expected, actual)
|
||||
|
|
Загрузка…
Ссылка в новой задаче