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
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Add support for `when 'T : Enum` library-only static optimization constraint. ([PR #18546](https://github.com/dotnet/fsharp/pull/18546))
* Add support for tail calls in computation expressions ([PR #18804](https://github.com/dotnet/fsharp/pull/18804))
* Add `--typecheck-only` flag support for F# Interactive (FSI) scripts to type-check without execution. ([Issue #18686](https://github.com/dotnet/fsharp/issues/18686))
* Diagnostics: add extended data for 'No constructors' error ([PR #18863](https://github.com/dotnet/fsharp/pull/18863))

### Fixed

Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,8 @@ module MutRecBindingChecking =
try
let baseTy, tpenv = TcType cenv NoNewTypars CheckCxs ItemOccurrence.Use WarnOnIWSAM.Yes envInstance tpenv synBaseTy
let baseTy = baseTy |> convertToTypeWithMetadataIfPossible g
TcNewExpr cenv envInstance tpenv baseTy (Some synBaseTy.Range) true arg m
let mTcNew = unionRanges synBaseTy.Range arg.Range
TcNewExpr cenv envInstance tpenv baseTy (Some synBaseTy.Range) true arg mTcNew
with RecoverableException e ->
errorRecovery e m
mkUnit g m, tpenv
Expand Down
4 changes: 3 additions & 1 deletion src/Compiler/Checking/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ open FSharp.Compiler.TypeHierarchy
open FSharp.Compiler.TypeProviders
#endif

exception NoConstructorsAvailableForType of TType * DisplayEnv * range

/// An object that captures the logical context for name resolution.
type NameResolver(g: TcGlobals,
amap: Import.ImportMap,
Expand Down Expand Up @@ -2554,7 +2556,7 @@ let private ResolveObjectConstructorPrim (ncenv: NameResolver) edenv resInfo m a
[DefaultStructCtor(g, ty)]
else []
if (isNil defaultStructCtorInfo && isNil ctorInfos) || (not (isAppTy g ty) && not (isAnyTupleTy g ty)) then
raze (Error(FSComp.SR.nrNoConstructorsAvailableForType(NicePrint.minimalStringOfType edenv ty), m))
raze (NoConstructorsAvailableForType(ty, edenv, m))
else
let ctorInfos = ctorInfos |> List.filter (IsMethInfoAccessible amap m ad)
let metadataTy = convertToTypeWithMetadataIfPossible g ty
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/Checking/NameResolution.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ open FSharp.Compiler.TypedTree
open FSharp.Compiler.TypedTreeOps
open FSharp.Compiler.TcGlobals

exception NoConstructorsAvailableForType of TType * DisplayEnv * range

/// A NameResolver is a context for name resolution. It primarily holds an InfoReader.
type NameResolver =

Expand Down
20 changes: 9 additions & 11 deletions src/Compiler/Driver/CompilerDiagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,24 @@ open FSharp.Compiler.TypedTreeOps
let showAssertForUnexpectedException = ref true
#endif

/// This exception is an old-style way of reporting a diagnostic
exception HashIncludeNotAllowedInNonScript of range

/// This exception is an old-style way of reporting a diagnostic
exception HashReferenceNotAllowedInNonScript of range

/// This exception is an old-style way of reporting a diagnostic
exception HashLoadedSourceHasIssues of informationals: exn list * warnings: exn list * errors: exn list * range

/// This exception is an old-style way of reporting a diagnostic
exception HashLoadedScriptConsideredSource of range

/// This exception is an old-style way of reporting a diagnostic
exception HashDirectiveNotAllowedInNonScript of range

/// This exception is an old-style way of reporting a diagnostic
exception DeprecatedCommandLineOptionFull of string * range

/// This exception is an old-style way of reporting a diagnostic
exception DeprecatedCommandLineOptionForHtmlDoc of string * range

/// This exception is an old-style way of reporting a diagnostic
exception DeprecatedCommandLineOptionSuggestAlternative of string * string * range

/// This exception is an old-style way of reporting a diagnostic
exception DeprecatedCommandLineOptionNoDescription of string * range

/// This exception is an old-style way of reporting a diagnostic
exception InternalCommandLineOption of string * range

type Exception with
Expand Down Expand Up @@ -207,7 +197,9 @@ type Exception with
| MSBuildReferenceResolutionError(_, _, m)
| AssemblyNotResolved(_, m)
| HashLoadedSourceHasIssues(_, _, _, m)
| HashLoadedScriptConsideredSource m -> Some m
| HashLoadedScriptConsideredSource m
| NoConstructorsAvailableForType(_, _, m) -> Some m

// Strip TargetInvocationException wrappers
| :? System.Reflection.TargetInvocationException as e when isNotNull e.InnerException -> (!!e.InnerException).DiagnosticRange
#if !NO_TYPEPROVIDERS
Expand Down Expand Up @@ -336,6 +328,7 @@ type Exception with
| PatternMatchCompilation.EnumMatchIncomplete _ -> 104
| Failure _ -> 192
| DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer _ -> 318
| NoConstructorsAvailableForType _ -> 1133
| ArgumentsInSigAndImplMismatch _ -> 3218

// Strip TargetInvocationException wrappers
Expand Down Expand Up @@ -616,6 +609,8 @@ module OldStyleMessages =
let InvalidAttributeTargetForLanguageElement1E () = Message("InvalidAttributeTargetForLanguageElement1", "%s%s")
let InvalidAttributeTargetForLanguageElement2E () = Message("InvalidAttributeTargetForLanguageElement2", "")

let NoConstructorsAvailableForTypeE () = Message("NoConstructorsAvailableForType", "%s")

#if DEBUG
let mutable showParserStackOnParseError = false
#endif
Expand Down Expand Up @@ -1945,6 +1940,9 @@ type Exception with
let allowedTargets = allowedTargets |> String.concat ", "
os.AppendString(InvalidAttributeTargetForLanguageElement1E().Format elementTargets allowedTargets)

| NoConstructorsAvailableForType(t, denv, _) ->
os.AppendString(NoConstructorsAvailableForTypeE().Format(NicePrint.minimalStringOfType denv t))

// Strip TargetInvocationException wrappers
| :? TargetInvocationException as e when isNotNull e.InnerException -> (!!e.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 @@ -1019,7 +1019,6 @@ lexfltInvalidNestedConstruct,"'%s' must be defined at module level, not inside a
1129,nrRecordDoesNotContainSuchLabel,"The record type '%s' does not contain a label '%s'."
1130,nrInvalidFieldLabel,"Invalid field label"
1132,nrInvalidExpression,"Invalid expression '%s'"
1133,nrNoConstructorsAvailableForType,"No constructors are available for the type '%s'"
1134,nrUnionTypeNeedsQualifiedAccess,"The union type for union case '%s' was defined with the RequireQualifiedAccessAttribute. Include the name of the union type ('%s') in the name you are using."
1135,nrRecordTypeNeedsQualifiedAccess,"The record type for the record field '%s' was defined with the RequireQualifiedAccessAttribute. Include the name of the record type ('%s') in the name you are using."
1136,ilwriteErrorCreatingPdb,"Unexpected error creating debug information file '%s'"
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/FSStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1152,4 +1152,7 @@
<data name="InvalidAttributeTargetForLanguageElement2" xml:space="preserve">
<value>This attribute is not valid for use on this language element</value>
</data>
<data name="NoConstructorsAvailableForType" xml:space="preserve">
<value>No constructors are available for the type '{0}'</value>
</data>
</root>
15 changes: 13 additions & 2 deletions src/Compiler/Symbols/FSharpDiagnostic.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ open System

open FSharp.Compiler.CheckExpressions
open FSharp.Compiler.ConstraintSolver
open FSharp.Compiler.NameResolution
open FSharp.Compiler.SignatureConformance
open FSharp.Compiler.Symbols
open FSharp.Compiler.Syntax
Expand Down Expand Up @@ -86,6 +87,12 @@ module ExtendedData =
member x.ContextInfo = context
member x.DisplayContext = FSharpDisplayContext(fun _ -> dispEnv)

type TypeExtendedData internal (symbolEnv: SymbolEnv, displayEnv: DisplayEnv, actualType: TType) =
interface IFSharpDiagnosticExtendedData

member x.Type = FSharpType(symbolEnv, actualType)
member x.DisplayContext = FSharpDisplayContext(fun _ -> displayEnv)

type ExpressionIsAFunctionExtendedData internal (symbolEnv: SymbolEnv, actualType: TType) =
interface IFSharpDiagnosticExtendedData

Expand Down Expand Up @@ -203,11 +210,15 @@ type FSharpDiagnostic(m: range, severity: FSharpDiagnosticSeverity, message: str
| DefinitionsInSigAndImplNotCompatibleAbbreviationsDiffer(implTycon = implTycon; sigTycon = sigTycon) ->
Some(DefinitionsInSigAndImplNotCompatibleAbbreviationsDifferExtendedData(sigTycon, implTycon))

| ObsoleteDiagnostic(diagnosticId= diagnosticId; urlFormat= urlFormat) ->
| ObsoleteDiagnostic(diagnosticId = diagnosticId; urlFormat = urlFormat) ->
Some(ObsoleteDiagnosticExtendedData(diagnosticId, urlFormat))

| Experimental(diagnosticId= diagnosticId; urlFormat= urlFormat) ->
| Experimental(diagnosticId = diagnosticId; urlFormat = urlFormat) ->
Some(ExperimentalExtendedData(diagnosticId, urlFormat))

| NoConstructorsAvailableForType(ttype, displayEnv, _) ->
Some(TypeExtendedData(symbolEnv, displayEnv, ttype))

| _ -> None

let msg =
Expand Down
7 changes: 7 additions & 0 deletions src/Compiler/Symbols/FSharpDiagnostic.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ module ExtendedData =
/// Represents the information needed to format types
member DisplayContext: FSharpDisplayContext

[<Class>]
type TypeExtendedData =
interface IFSharpDiagnosticExtendedData

member Type: FSharpType
member DisplayContext: FSharpDisplayContext

/// Additional data for 'This expression is a function value, i.e. is missing arguments' diagnostic
[<Class>]
type ExpressionIsAFunctionExtendedData =
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.

5 changes: 0 additions & 5 deletions src/Compiler/xlf/FSComp.txt.pt-BR.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.ru.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.tr.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.zh-Hans.xlf

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

Loading
Loading