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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6565,8 +6565,14 @@ and TcRecordConstruction (cenv: cenv) (overallTy: TType) env tpenv withExprInfoO
let ns1 = NameSet.ofList (List.map fst fldsList)
let ns2 = NameSet.ofList (List.map (fun x -> x.rfield_id.idText) fspecs)

if withExprInfoOpt.IsNone && not (Zset.subset ns2 ns1) then
error (MissingFields(Zset.elements (Zset.diff ns2 ns1), m))
match withExprInfoOpt with
| None ->
if not (Zset.subset ns2 ns1) then
error(MissingFields(Zset.elements (Zset.diff ns2 ns1), m))
| _ ->
if oldFldsList.IsEmpty then
let enabledByLangFeature = g.langVersion.SupportsFeature LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields
warning(ErrorEnabledWithLanguageFeature(FSComp.SR.tcCopyAndUpdateRecordChangesAllFields(fullDisplayTextOfTyconRef tcref), m, enabledByLangFeature))

if not (Zset.subset ns1 ns2) then
error (Error(FSComp.SR.tcExtraneousFieldsGivenValues(), m))
Expand Down
13 changes: 10 additions & 3 deletions src/Compiler/Driver/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ type Exception with
| LetRecEvaluatedOutOfOrder (_, _, _, m)
| DiagnosticWithText (_, _, m)
| DiagnosticWithSuggestions (_, _, m, _, _)
| DiagnosticEnabledWithLanguageFeature (_, _, m, _)
| SyntaxError (_, m)
| InternalError (_, m)
| InterfaceNotRevealed (_, _, m)
Expand Down Expand Up @@ -330,6 +331,7 @@ type Exception with
| WrappedError (e, _) -> e.DiagnosticNumber
| DiagnosticWithText (n, _, _) -> n
| DiagnosticWithSuggestions (n, _, _, _, _) -> n
| DiagnosticEnabledWithLanguageFeature (n, _, _, _) -> n
| Failure _ -> 192
| IllegalFileNameChar (fileName, invalidChar) -> fst (FSComp.SR.buildUnexpectedFileNameCharacter (fileName, string invalidChar))
#if !NO_TYPEPROVIDERS
Expand All @@ -353,6 +355,7 @@ type PhasedDiagnostic with
| DefensiveCopyWarning _ -> 5

| DiagnosticWithText (n, _, _)
| DiagnosticEnabledWithLanguageFeature (n, _, _, _)
| DiagnosticWithSuggestions (n, _, _, _, _) ->
// 1178, tcNoComparisonNeeded1, "The struct, record or union type '%s' is not structurally comparable because the type parameter %s does not satisfy the 'comparison' constraint..."
// 1178, tcNoComparisonNeeded2, "The struct, record or union type '%s' is not structurally comparable because the type '%s' does not satisfy the 'comparison' constraint...."
Expand Down Expand Up @@ -382,8 +385,11 @@ type PhasedDiagnostic with
| 3395 -> false // tcImplicitConversionUsedForMethodArg - off by default
| 3559 -> false // typrelNeverRefinedAwayFromTop - off by default
| _ ->
(severity = FSharpDiagnosticSeverity.Info)
|| (severity = FSharpDiagnosticSeverity.Warning && level >= x.WarningLevel)
match x.Exception with
| DiagnosticEnabledWithLanguageFeature (_, _, _, enabled) -> enabled
| _ ->
(severity = FSharpDiagnosticSeverity.Info)
|| (severity = FSharpDiagnosticSeverity.Warning && level >= x.WarningLevel)

/// Indicates if a diagnostic should be reported as an informational
member x.ReportAsInfo(options, severity) =
Expand Down Expand Up @@ -1655,7 +1661,8 @@ type Exception with

os.AppendString(NonUniqueInferredAbstractSlot4E().Format)

| DiagnosticWithText (_, s, _) -> os.AppendString s
| DiagnosticWithText (_, s, _)
| DiagnosticEnabledWithLanguageFeature (_, s, _, _) -> os.AppendString s

| DiagnosticWithSuggestions (_, s, _, idText, suggestionF) ->
os.AppendString(ConvertValLogicalNameToDisplayNameCore s)
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@ featureErrorForNonVirtualMembersOverrides,"Raises errors for non-virtual members
featureWarningWhenInliningMethodImplNoInlineMarkedFunction,"Raises warnings when 'let inline ... =' is used together with [<MethodImpl(MethodImplOptions.NoInlining)>] attribute. Function is not getting inlined."
featureArithmeticInLiterals,"Allow arithmetic and logical operations in literals"
featureErrorReportingOnStaticClasses,"Error reporting on static classes"
featureWarningWhenCopyAndUpdateRecordChangesAllFields,"Raises warnings when an copy-and-update record expression changes all fields of a record."
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."
Expand Down Expand Up @@ -1674,3 +1675,4 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form
3557,chkAbstractMembersDeclarationsOnStaticClasses,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Abstract member declarations are not allowed."
3558,chkExplicitFieldsDeclarationsOnStaticClasses,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed."
3559,typrelNeverRefinedAwayFromTop,"A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'."
3560,tcCopyAndUpdateRecordChangesAllFields,"This copy-and-update record expression changes all fields of record type '%s'. Consider using the record construction syntax instead."
6 changes: 6 additions & 0 deletions src/Compiler/Facilities/DiagnosticsLogger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ exception DiagnosticWithSuggestions of number: int * message: string * range: ra
| DiagnosticWithSuggestions (_, msg, _, _, _) -> msg
| _ -> "impossible"

/// A diagnostic that is raised when enabled manually, or by default with a language feature
exception DiagnosticEnabledWithLanguageFeature of number: int * message: string * range: range * enabledByLangFeature: bool

/// The F# compiler code currently uses 'Error(...)' in many places to create
/// an DiagnosticWithText as an exception even if it's a warning.
///
Expand All @@ -126,6 +129,9 @@ let Error ((n, text), m) = DiagnosticWithText(n, text, m)
let ErrorWithSuggestions ((n, message), m, id, suggestions) =
DiagnosticWithSuggestions(n, message, m, id, suggestions)

let ErrorEnabledWithLanguageFeature ((n, message), m, enabledByLangFeature) =
DiagnosticEnabledWithLanguageFeature (n, message, m, enabledByLangFeature)

let inline protectAssemblyExploration dflt f =
try
f ()
Expand Down
10 changes: 10 additions & 0 deletions src/Compiler/Facilities/DiagnosticsLogger.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ val StopProcessing<'T> : exn
/// Represents a diagnostic exeption whose text comes via SR.*
exception DiagnosticWithText of number: int * message: string * range: range

/// A diagnostic that is raised when enabled manually, or by default with a language feature
exception DiagnosticEnabledWithLanguageFeature of
number: int *
message: string *
range: range *
enabledByLangFeature: bool

/// Creates a diagnostic exeption whose text comes via SR.*
val Error: (int * string) * range -> exn

Expand Down Expand Up @@ -77,6 +84,9 @@ exception DiagnosticWithSuggestions of
/// Creates a DiagnosticWithSuggestions whose text comes via SR.*
val ErrorWithSuggestions: (int * string) * range * string * Suggestions -> exn

/// Creates a DiagnosticEnabledWithLanguageFeature whose text comes via SR.*
val ErrorEnabledWithLanguageFeature: (int * string) * range * bool -> exn

val inline protectAssemblyExploration: dflt: 'T -> f: (unit -> 'T) -> 'T

val inline protectAssemblyExplorationF: dflt: (string * string -> 'T) -> f: (unit -> 'T) -> 'T
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type LanguageFeature =
| EscapeDotnetFormattableStrings
| ArithmeticInLiterals
| ErrorReportingOnStaticClasses
| WarningWhenCopyAndUpdateRecordChangesAllFields

/// LanguageVersion management
type LanguageVersion(versionText) =
Expand Down Expand Up @@ -138,6 +139,7 @@ type LanguageVersion(versionText) =
LanguageFeature.EscapeDotnetFormattableStrings, previewVersion
LanguageFeature.ArithmeticInLiterals, previewVersion
LanguageFeature.ErrorReportingOnStaticClasses, previewVersion
LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields, previewVersion

]

Expand Down Expand Up @@ -252,6 +254,7 @@ type LanguageVersion(versionText) =
| LanguageFeature.EscapeDotnetFormattableStrings -> FSComp.SR.featureEscapeBracesInFormattableString ()
| LanguageFeature.ArithmeticInLiterals -> FSComp.SR.featureArithmeticInLiterals ()
| LanguageFeature.ErrorReportingOnStaticClasses -> FSComp.SR.featureErrorReportingOnStaticClasses ()
| LanguageFeature.WarningWhenCopyAndUpdateRecordChangesAllFields -> FSComp.SR.featureWarningWhenCopyAndUpdateRecordChangesAllFields ()

/// Get a version string associated with the given feature.
static member GetFeatureVersionString feature =
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Facilities/LanguageFeatures.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type LanguageFeature =
| EscapeDotnetFormattableStrings
| ArithmeticInLiterals
| ErrorReportingOnStaticClasses
| WarningWhenCopyAndUpdateRecordChangesAllFields

/// LanguageVersion management
type LanguageVersion =
Expand Down
16 changes: 8 additions & 8 deletions src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5983,14 +5983,14 @@ and remapUnionCases ctxt tmenv (x: TyconUnionData) =
x.UnionCasesAsList |> List.map (remapUnionCase ctxt tmenv) |> Construct.MakeUnionCases

and remapFsObjData ctxt tmenv x =
{ x with
fsobjmodel_kind =
(match x.fsobjmodel_kind with
| TFSharpDelegate slotsig -> TFSharpDelegate (remapSlotSig (remapAttribs ctxt tmenv) tmenv slotsig)
| TFSharpClass | TFSharpInterface | TFSharpStruct | TFSharpEnum -> x.fsobjmodel_kind)
fsobjmodel_vslots = x.fsobjmodel_vslots |> List.map (remapValRef tmenv)
fsobjmodel_rfields = x.fsobjmodel_rfields |> remapRecdFields ctxt tmenv }

{
fsobjmodel_kind =
match x.fsobjmodel_kind with
| TFSharpDelegate slotsig -> TFSharpDelegate (remapSlotSig (remapAttribs ctxt tmenv) tmenv slotsig)
| TFSharpClass | TFSharpInterface | TFSharpStruct | TFSharpEnum -> x.fsobjmodel_kind
fsobjmodel_vslots = x.fsobjmodel_vslots |> List.map (remapValRef tmenv)
fsobjmodel_rfields = x.fsobjmodel_rfields |> remapRecdFields ctxt tmenv
}

and remapTyconRepr ctxt tmenv repr =
match repr with
Expand Down
10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@
<target state="translated">reprezentace struktury aktivních vzorů</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenCopyAndUpdateRecordChangesAllFields">
<source>Raises warnings when an copy-and-update record expression changes all fields of a record.</source>
<target state="new">Raises warnings when an copy-and-update record expression changes all fields of a record.</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="translated">Vyvolá upozornění, když se použije „let inline ... =“ společně s atributem [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;]. Funkce není vkládána.</target>
Expand Down Expand Up @@ -872,6 +877,11 @@
<target state="translated">Atributy nejde použít pro rozšíření typů.</target>
<note />
</trans-unit>
<trans-unit id="tcCopyAndUpdateRecordChangesAllFields">
<source>This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead.</source>
<target state="new">This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead.</target>
<note />
</trans-unit>
<trans-unit id="tcHighPrecedenceFunctionApplicationToListDeprecated">
<source>The syntax 'expr1[expr2]' is used for indexing. Consider adding a type annotation to enable indexing, or if calling a function add a space, e.g. 'expr1 [expr2]'.</source>
<target state="translated">Syntaxe expr1[expr2] se používá pro indexování. Pokud chcete povolit indexování, zvažte možnost přidat anotaci typu, nebo pokud voláte funkci, přidejte mezeru, třeba expr1 [expr2].</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@
<target state="translated">Strukturdarstellung für aktive Muster</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenCopyAndUpdateRecordChangesAllFields">
<source>Raises warnings when an copy-and-update record expression changes all fields of a record.</source>
<target state="new">Raises warnings when an copy-and-update record expression changes all fields of a record.</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="translated">Löst Warnungen aus, wenn „let inline ... =“ zusammen mit dem Attribut [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] verwendet wird. Die Funktion wird nicht inline gesetzt.</target>
Expand Down Expand Up @@ -872,6 +877,11 @@
<target state="translated">Attribute können nicht auf Typerweiterungen angewendet werden.</target>
<note />
</trans-unit>
<trans-unit id="tcCopyAndUpdateRecordChangesAllFields">
<source>This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead.</source>
<target state="new">This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead.</target>
<note />
</trans-unit>
<trans-unit id="tcHighPrecedenceFunctionApplicationToListDeprecated">
<source>The syntax 'expr1[expr2]' is used for indexing. Consider adding a type annotation to enable indexing, or if calling a function add a space, e.g. 'expr1 [expr2]'.</source>
<target state="translated">Die Syntax "expr1[expr2]" wird für die Indizierung verwendet. Fügen Sie ggf. eine Typanmerkung hinzu, um die Indizierung zu aktivieren, oder fügen Sie beim Aufrufen einer Funktion ein Leerzeichen hinzu, z. B. "expr1 [expr2]".</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@
<target state="translated">representación de struct para modelos activos</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenCopyAndUpdateRecordChangesAllFields">
<source>Raises warnings when an copy-and-update record expression changes all fields of a record.</source>
<target state="new">Raises warnings when an copy-and-update record expression changes all fields of a record.</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="translated">Genera advertencias cuando se usa "let inline ... =" junto con el atributo [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;]. La función no se está insertando.</target>
Expand Down Expand Up @@ -872,6 +877,11 @@
<target state="translated">Los atributos no se pueden aplicar a las extensiones de tipo.</target>
<note />
</trans-unit>
<trans-unit id="tcCopyAndUpdateRecordChangesAllFields">
<source>This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead.</source>
<target state="new">This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead.</target>
<note />
</trans-unit>
<trans-unit id="tcHighPrecedenceFunctionApplicationToListDeprecated">
<source>The syntax 'expr1[expr2]' is used for indexing. Consider adding a type annotation to enable indexing, or if calling a function add a space, e.g. 'expr1 [expr2]'.</source>
<target state="translated">La sintaxis "expr1[expr2]" se usa para la indexación. Considere la posibilidad de agregar una anotación de tipo para habilitar la indexación, si se llama a una función, agregue un espacio, por ejemplo, "expr1 [expr2]".</target>
Expand Down
10 changes: 10 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@
<target state="translated">représentation de structure pour les modèles actifs</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenCopyAndUpdateRecordChangesAllFields">
<source>Raises warnings when an copy-and-update record expression changes all fields of a record.</source>
<target state="new">Raises warnings when an copy-and-update record expression changes all fields of a record.</target>
<note />
</trans-unit>
<trans-unit id="featureWarningWhenInliningMethodImplNoInlineMarkedFunction">
<source>Raises warnings when 'let inline ... =' is used together with [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;] attribute. Function is not getting inlined.</source>
<target state="translated">Génère des avertissements lorsque « let inline ... = » est utilisé avec l’attribut [&lt;MethodImpl(MethodImplOptions.NoInlining)&gt;]. La fonction n’est pas inlined.</target>
Expand Down Expand Up @@ -872,6 +877,11 @@
<target state="translated">Impossible d'appliquer des attributs aux extensions de type.</target>
<note />
</trans-unit>
<trans-unit id="tcCopyAndUpdateRecordChangesAllFields">
<source>This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead.</source>
<target state="new">This copy-and-update record expression changes all fields of record type '{0}'. Consider using the record construction syntax instead.</target>
<note />
</trans-unit>
<trans-unit id="tcHighPrecedenceFunctionApplicationToListDeprecated">
<source>The syntax 'expr1[expr2]' is used for indexing. Consider adding a type annotation to enable indexing, or if calling a function add a space, e.g. 'expr1 [expr2]'.</source>
<target state="translated">La syntaxe « expr1[expr2] » est utilisée pour l’indexation. Envisagez d’ajouter une annotation de type pour activer l’indexation, ou si vous appelez une fonction, ajoutez un espace, par exemple « expr1 [expr2] ».</target>
Expand Down
Loading