-
Notifications
You must be signed in to change notification settings - Fork 833
Open
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingArea-Compiler-SRTPbugs in SRTP inference, resolution, witness passing, code genbugs in SRTP inference, resolution, witness passing, code genBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.Regression
Milestone
Description
Consider the following code:
type T() = class end
let dosmth (a: T) = System.Console.WriteLine a
let inline NEW () = (^a : (new : unit -> ^a) ())
let x = NEW ()
dosmth x
Typechecks without issues with --langversion:6.0
:
> type T() = class end
- let dosmth (a: T) = System.Console.WriteLine a
- let inline NEW () = (^a : (new : unit -> ^a) ())
- let x = NEW ()
- dosmth x;;
FSI_0002+T
type T =
new: unit -> T
val dosmth: a: T -> unit
val inline NEW: unit -> ^a when ^a: (``.ctor`` : ^a)
val x: T
val it: unit = ()
>
Fails with --langversion:7.0
and higher:
> type T() = class end
- let dosmth (a: T) = System.Console.WriteLine a
- let inline NEW () = (^a : (new : unit -> ^a) ())
- let x = NEW ()
- dosmth x;;
let x = NEW ()
----^
stdin(4,5): error FS0030: Value restriction. The value 'x' has been inferred to have generic type
val x: '_a when '_a: (``.ctor`` : '_a) and '_a :> T
Either define 'x' as a simple data term, make it a function with explicit arguments or, if you do not intend for it to be generic, add a type annotation.
Looking through the features list for 7.0 it's probably regressed in one of the following:
LanguageFeature.InterfacesWithAbstractStaticMembers
LanguageFeature.SelfTypeConstraints
haraldsteinlechner
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingArea-Compiler-SRTPbugs in SRTP inference, resolution, witness passing, code genbugs in SRTP inference, resolution, witness passing, code genBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.Regression