Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Compiler/Checking/CheckPatterns.fs
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,7 @@ and TcPatLongIdentNewDef warnOnUpperForId warnOnUpper (cenv: cenv) env ad valRep
| [] ->
TcPat warnOnUpperForId cenv env valReprInfo vFlags patEnv ty (mkSynPatVar vis id)

| [arg]
when g.langVersion.SupportsFeature LanguageFeature.NameOf && IsNameOf cenv env ad m id ->
| [arg] when IsNameOf cenv env ad m id ->
match TcNameOfExpr cenv env tpenv (ConvSynPatToSynExpr arg) with
| Expr.Const(Const.String s, m, _) ->
// Record the resolution of the `nameof` usage so that we can classify it correctly later.
Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8990,7 +8990,7 @@ and TcApplicationThen (cenv: cenv) (overallTy: OverallTy) env tpenv mExprAndArg
checkHighPrecedenceFunctionApplicationToList [synArg] atomicFlag mExprAndArg

match leftExpr with
| ApplicableExpr(expr=NameOfExpr g _) when g.langVersion.SupportsFeature LanguageFeature.NameOf ->
| ApplicableExpr(expr=NameOfExpr g _) ->
let replacementExpr = TcNameOfExpr cenv env tpenv synArg
TcDelayed cenv overallTy env tpenv mExprAndArg (ApplicableExpr(cenv, replacementExpr, true, None)) g.string_ty ExprAtomicFlag.Atomic delayed
| _ ->
Expand Down Expand Up @@ -9726,7 +9726,7 @@ and TcValueItemThen cenv overallTy env vref tpenv mItem mItemIdent afterResoluti
// - it isn't a VSlotDirectCall (uses of base values do not take type arguments
// Allow `nameof<'T>` for a generic parameter
match vref with
| _ when isNameOfValRef g vref && g.langVersion.SupportsFeature LanguageFeature.NameOf ->
| _ when isNameOfValRef g vref ->
// Record the resolution of the `nameof` usage so that we can classify it correctly later.
do
match afterResolution with
Expand Down
30 changes: 4 additions & 26 deletions src/Compiler/Checking/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ type NameResolver(g: TcGlobals,
member nr.g = g
member nr.amap = amap
member nr.InfoReader = infoReader
member nr.languageSupportsNameOf = g.langVersion.SupportsFeature LanguageFeature.NameOf

//-------------------------------------------------------------------------
// Helpers for unionconstrs and recdfields
Expand Down Expand Up @@ -3468,15 +3467,6 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified

let lookupKind = LookupKind.Expr LookupIsInstance.No

let canSuggestThisItem (item:Item) =
// All items can be suggested except nameof when it comes from FSharp.Core.dll and the nameof feature is not enabled
match item with
| Item.Value v ->
let isNameOfOperator = valRefEq ncenv.g ncenv.g.nameof_vref v
if isNameOfOperator && not (ncenv.g.langVersion.SupportsFeature LanguageFeature.NameOf) then false
else true
| _ -> true

if first && id.idText = MangledGlobalName then
match rest with
| [] ->
Expand Down Expand Up @@ -3515,15 +3505,7 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified

| true, res ->
let fresh = ResolveUnqualifiedItem ncenv nenv m res
match fresh with
| Item.Value value ->
let isNameOfOperator = valRefEq ncenv.g ncenv.g.nameof_vref value
if isNameOfOperator && not ncenv.languageSupportsNameOf then
// Do not resolve `nameof` if the feature is unsupported, even if it is FSharp.Core
None
else
Some (emptyEnclosingTypeInst, fresh, rest)
| _ -> Some (emptyEnclosingTypeInst, fresh, rest)
Some (emptyEnclosingTypeInst, fresh, rest)
| _ ->
None

Expand Down Expand Up @@ -3574,8 +3556,7 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified

let suggestNamesAndTypes (addToBuffer: string -> unit) =
for e in nenv.eUnqualifiedItems do
if canSuggestThisItem e.Value then
addToBuffer e.Value.DisplayName
addToBuffer e.Value.DisplayName

for e in nenv.TyconsByDemangledNameAndArity fullyQualified do
if IsEntityAccessible ncenv.amap m ad e.Value then
Expand Down Expand Up @@ -3671,8 +3652,7 @@ let rec ResolveExprLongIdentPrim sink (ncenv: NameResolver) first fullyQualified
addToBuffer tcref.DisplayName

for KeyValue(_,item) in nenv.eUnqualifiedItems do
if canSuggestThisItem item then
addToBuffer item.DisplayName
addToBuffer item.DisplayName

match innerSearch with
| Exception (UndefinedName(0, _, id1, suggestionsF)) when equals id.idRange id1.idRange ->
Expand Down Expand Up @@ -4739,9 +4719,7 @@ let IsUnionCaseUnseen ad g amap m allowObsolete (ucref: UnionCaseRef) =

let ItemIsUnseen ad g amap m allowObsolete item =
match item with
| Item.Value x ->
let isUnseenNameOfOperator = valRefEq g g.nameof_vref x && not (g.langVersion.SupportsFeature LanguageFeature.NameOf)
isUnseenNameOfOperator || IsValUnseen ad g m allowObsolete x
| Item.Value x -> IsValUnseen ad g m allowObsolete x
| Item.UnionCase(x, _) -> IsUnionCaseUnseen ad g amap m allowObsolete x.UnionCaseRef
| Item.ExnCase x -> IsTyconUnseen ad g amap m allowObsolete x
| Item.ILField finfo -> not allowObsolete && ILFieldInfoIsUnseen finfo
Expand Down
2 changes: 0 additions & 2 deletions src/Compiler/Checking/NameResolution.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ type NameResolver =

member g: TcGlobals

member languageSupportsNameOf: bool

/// Get the active pattern elements defined in a module, if any. Cache in the slot in the module type.
val ActivePatternElemsOfModuleOrNamespace: g: TcGlobals -> ModuleOrNamespaceRef -> NameMap<ActivePatternElemRef>

Expand Down
3 changes: 1 addition & 2 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,6 @@ optsAlwaysInline,"Always inline 'inline' functions"
nativeResourceFormatError,"Stream does not begin with a null resource and is not in '.RES' format."
nativeResourceHeaderMalformed,"Resource header beginning at offset %s is malformed."
formatDashItem," - %s"
featureNameOf,"nameof"
featureDotlessFloat32Literal,"dotless float32 literal"
featurePackageManagement,"package management"
featureFromEndSlicing,"from-end slicing"
Expand Down Expand Up @@ -1788,7 +1787,7 @@ featurePreprocessorElif,"#elif preprocessor directive"
featureExtensionConstraintSolutions,"Allow extension members to participate in SRTP constraint resolution"
featureErrorOnBitwiseOpsOnNonIntegralEnums,"Error when bitwise operators are used on enums whose underlying type is not an integer type (e.g. char)."
3880,optsLangVersionOutOfSupport,"Language version '%s' is out of support. The last .NET SDK supporting it is available at https://dotnet.microsoft.com/en-us/download/dotnet/%s"
3881,optsUnrecognizedLanguageFeature,"Unrecognized language feature name: '%s'. Use a valid feature name such as 'NameOf' or 'StringInterpolation'."
3881,optsUnrecognizedLanguageFeature,"Unrecognized language feature name: '%s'. Use a valid feature name such as 'StringInterpolation' or 'FromEndSlicing'."
3882,lexHashElifMustBeFirst,"#elif directive must appear as the first non-whitespace character on a line"
3883,lexHashElifMustHaveIdent,"#elif directive should be immediately followed by an identifier"
3884,tcFunctionValueUsedAsInterpolatedStringArg,"This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments."
Expand Down
3 changes: 0 additions & 3 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module internal FSharp.Compiler.Features

[<RequireQualifiedAccess>]
type LanguageFeature =
| NameOf
| DotlessFloat32Literal
| PackageManagement
| FromEndSlicing
Expand Down Expand Up @@ -142,7 +141,6 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array)
LanguageFeature.DefaultInterfaceMemberConsumption, languageVersion50
LanguageFeature.PackageManagement, languageVersion50
LanguageFeature.WitnessPassing, languageVersion50
LanguageFeature.NameOf, languageVersion50
LanguageFeature.StringInterpolation, languageVersion50

// F# 6.0
Expand Down Expand Up @@ -328,7 +326,6 @@ type LanguageVersion(versionText, ?disabledFeaturesArray: LanguageFeature array)
/// Get a string name for the given feature.
static member GetFeatureString feature =
match feature with
| LanguageFeature.NameOf -> FSComp.SR.featureNameOf ()
| LanguageFeature.DotlessFloat32Literal -> FSComp.SR.featureDotlessFloat32Literal ()
| LanguageFeature.PackageManagement -> FSComp.SR.featurePackageManagement ()
| LanguageFeature.FromEndSlicing -> FSComp.SR.featureFromEndSlicing ()
Expand Down
1 change: 0 additions & 1 deletion src/Compiler/Facilities/LanguageFeatures.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module internal FSharp.Compiler.Features
/// LanguageFeature enumeration
[<RequireQualifiedAccess>]
type LanguageFeature =
| NameOf
| DotlessFloat32Literal
| PackageManagement
| FromEndSlicing
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/TypedTree/TypedTreeOps.Transforms.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2351,7 +2351,7 @@ module internal ConstantEvaluation =
| UncheckedDefaultOfExpr g _
| SizeOfExpr g _
| TypeOfExpr g _ -> true
| NameOfExpr g _ when g.langVersion.SupportsFeature LanguageFeature.NameOf -> true
| NameOfExpr g _ -> true
// All others are not simple constant expressions
| _ -> false

Expand Down
9 changes: 2 additions & 7 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/Compiler/xlf/FSComp.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/Compiler/xlf/FSComp.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/Compiler/xlf/FSComp.txt.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading