Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 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
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Add switch to generate types and members with IL visibility that accurately represents their F# visibility. ([PR #15484](https://github.com/dotnet/fsharp/pull/15484)
* Allow returning bool instead of unit option for partial active patterns. ([Language suggestion #1041](https://github.com/fsharp/fslang-suggestions/issues/1041), [PR #16473](https://github.com/dotnet/fsharp/pull/16473))
* Symbols: Add GenericArguments to FSharpEntity ([PR #16470](https://github.com/dotnet/fsharp/pull/16470))
* Add extended data for `DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer` (FS0318). ([PR #16811](https://github.com/dotnet/fsharp/pull/16811)))

### Changed

Expand Down
11 changes: 9 additions & 2 deletions src/Compiler/Checking/SignatureConformance.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ exception InterfaceNotRevealed of DisplayEnv * TType * range

exception ArgumentsInSigAndImplMismatch of sigArg: Ident * implArg: Ident

exception DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer of
denv: DisplayEnv *
implTycon:Tycon *
sigTycon:Tycon *
implTypeAbbrev:TType *
sigTypeAbbrev:TType *
range: range

// Use a type to capture the constant, common parameters
type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) =

Expand Down Expand Up @@ -589,8 +597,7 @@ type Checker(g, amap, denv, remapInfo: SignatureRepackageInfo, checkingSig) =
match implTycon.TypeAbbrev, sigTycon.TypeAbbrev with
| Some ty1, Some ty2 ->
if not (typeAEquiv g aenv ty1 ty2) then
let s1, s2, _ = NicePrint.minimalStringsOfTwoTypes denv ty1 ty2
errorR (Error (FSComp.SR.DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(implTycon.TypeOrMeasureKind.ToString(), implTycon.DisplayName, s1, s2), m))
errorR (DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(denv, implTycon, sigTycon, ty1, ty2, m))
false
else
true
Expand Down
8 changes: 8 additions & 0 deletions src/Compiler/Checking/SignatureConformance.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ exception InterfaceNotRevealed of DisplayEnv * TType * range

exception ArgumentsInSigAndImplMismatch of sigArg: Ident * implArg: Ident

exception DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer of
denv: DisplayEnv *
implTycon: Tycon *
sigTycon: Tycon *
implTypeAbbrev: TType *
sigTypeAbbrev: TType *
range: range

type Checker =

new:
Expand Down
16 changes: 16 additions & 0 deletions src/Compiler/Driver/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type Exception with

member exn.DiagnosticRange =
match exn with
| DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(range = m) -> Some m
| ArgumentsInSigAndImplMismatch(_, implArg) -> Some implArg.idRange
| ErrorFromAddingConstraint(_, exn2, _) -> exn2.DiagnosticRange
#if !NO_TYPEPROVIDERS
Expand Down Expand Up @@ -320,6 +321,7 @@ type Exception with
| BadEventTransformation _ -> 91
| HashLoadedScriptConsideredSource _ -> 92
| UnresolvedConversionOperator _ -> 93
| DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer _ -> 318
| ArgumentsInSigAndImplMismatch _ -> 3218
// avoid 94-100 for safety
| ObsoleteError _ -> 101
Expand Down Expand Up @@ -606,6 +608,9 @@ module OldStyleMessages =
let TargetInvocationExceptionWrapperE () = Message("TargetInvocationExceptionWrapper", "%s")
let ArgumentsInSigAndImplMismatchE () = Message("ArgumentsInSigAndImplMismatch", "%s%s")

let DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferE () =
Message("DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer", "%s%s%s%s")

#if DEBUG
let mutable showParserStackOnParseError = false
#endif
Expand Down Expand Up @@ -1857,6 +1862,17 @@ type Exception with
| ArgumentsInSigAndImplMismatch(sigArg, implArg) ->
os.AppendString(ArgumentsInSigAndImplMismatchE().Format sigArg.idText implArg.idText)

| DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(denv, implTycon, _sigTycon, implTypeAbbrev, sigTypeAbbrev, _m) ->
let s1, s2, _ = NicePrint.minimalStringsOfTwoTypes denv implTypeAbbrev sigTypeAbbrev

os.AppendString(
DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferE().Format
(implTycon.TypeOrMeasureKind.ToString())
implTycon.DisplayName
s1
s2
)

// Strip TargetInvocationException wrappers
| :? TargetInvocationException as exn -> exn.InnerException.Output(os, suggestNames)

Expand Down
1 change: 0 additions & 1 deletion src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ ValueNotContainedMutabilityInstanceButStatic,"Module '%s' contains\n %s \n
315,DefinitionsInSigAndImplNotCompatibleAbstractMemberMissingInImpl,"The %s definitions for type '%s' in the signature and implementation are not compatible because the abstract member '%s' was required by the signature but was not specified by the implementation"
316,DefinitionsInSigAndImplNotCompatibleAbstractMemberMissingInSig,"The %s definitions for type '%s' in the signature and implementation are not compatible because the abstract member '%s' was present in the implementation but not in the signature"
317,DefinitionsInSigAndImplNotCompatibleSignatureDeclaresDiffer,"The %s definitions for type '%s' in the signature and implementation are not compatible because the signature declares a %s while the implementation declares a %s"
318,DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer,"The %s definitions for type '%s' in the signature and implementation are not compatible because the abbreviations differ: %s versus %s"
319,DefinitionsInSigAndImplNotCompatibleAbbreviationHiddenBySig,"The %s definitions for type '%s' in the signature and implementation are not compatible because an abbreviation is being hidden by a signature. The abbreviation must be visible to other CLI languages. Consider making the abbreviation visible in the signature."
320,DefinitionsInSigAndImplNotCompatibleSigHasAbbreviation,"The %s definitions for type '%s' in the signature and implementation are not compatible because the signature has an abbreviation while the implementation does not"
ModuleContainsConstructorButNamesDiffer,"The module contains the constructor\n %s \nbut its signature specifies\n %s \nThe names differ"
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/FSStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,9 @@
<data name="ArgumentsInSigAndImplMismatch" xml:space="preserve">
<value>The argument names in the signature '{0}' and implementation '{1}' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling.</value>
</data>
<data name="DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer" xml:space="preserve">
<value>The {0} definitions for type '{1}' in the signature and implementation are not compatible because the abbreviations differ:\n {2}\nversus\n {3}</value>
</data>
<data name="Parser.TOKEN.WHILE.BANG" xml:space="preserve">
<value>keyword 'while!'</value>
</data>
Expand Down
10 changes: 10 additions & 0 deletions src/Compiler/Symbols/FSharpDiagnostic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ module ExtendedData =
member x.ImplementationName = implArg.idText
member x.SignatureRange = sigArg.idRange
member x.ImplementationRange = implArg.idRange

[<Class; Experimental("This FCS API is experimental and subject to change.")>]
type DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData
internal(signatureType: Tycon, implementationType: Tycon) =
interface IFSharpDiagnosticExtendedData
member x.SignatureRange: range = signatureType.Range
member x.ImplementationRange: range = implementationType.Range

open ExtendedData

Expand Down Expand Up @@ -191,6 +198,9 @@ type FSharpDiagnostic(m: range, severity: FSharpDiagnosticSeverity, message: str
| ArgumentsInSigAndImplMismatch(sigArg, implArg) ->
Some(ArgumentsInSigAndImplMismatchExtendedData(sigArg, implArg))

| DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(implTycon = implTycon; sigTycon = sigTycon) ->
Some(DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData(sigTycon, implTycon))

| _ -> None

let msg =
Expand Down
8 changes: 8 additions & 0 deletions src/Compiler/Symbols/FSharpDiagnostic.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ module public ExtendedData =
/// Argument identifier range within implementation file
member ImplementationRange: range

[<Class; Experimental("This FCS API is experimental and subject to change.")>]
type DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData =
interface IFSharpDiagnosticExtendedData
/// Range of the signature type identifier.
member SignatureRange: range
/// Range of the implementation type identifier.
member ImplementationRange: range

open ExtendedData

/// Represents a diagnostic produced by the F# compiler
Expand Down
5 changes: 0 additions & 5 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.

5 changes: 0 additions & 5 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.

5 changes: 0 additions & 5 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.

5 changes: 0 additions & 5 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.

5 changes: 0 additions & 5 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.

5 changes: 0 additions & 5 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.

5 changes: 0 additions & 5 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.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.pl.xlf

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

Loading