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
21 changes: 15 additions & 6 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3906,7 +3906,7 @@ type DelayedItem =

/// DelayedApp (isAtomic, argExpr, mFuncAndArg)
///
/// Represents the args in "item args", or "item.[args]".
/// Represents the args in "item args", or "item.[args]".
| DelayedApp of ExprAtomicFlag * Ast.SynExpr * range

/// Represents the long identifiers in "item.Ident1", or "item.Ident1.Ident2" etc.
Expand Down Expand Up @@ -5323,7 +5323,15 @@ and RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv e
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects cenv env tpenv arg
dummyCheckedDelayed otherDelayed
| _ -> ()
dummyCheckedDelayed delayed
dummyCheckedDelayed delayed

// Calls UnifyTypes, but upon error only does the minimal error recovery
// so that IntelliSense information can continue to be collected.
and UnifyTypesAndRecover cenv env m expectedTy actualTy =
try
UnifyTypes cenv env m expectedTy actualTy
with e ->
errorRecovery e m

and TcExprOfUnknownType cenv env tpenv expr =
let exprty = NewInferenceType ()
Expand Down Expand Up @@ -8089,7 +8097,7 @@ and PropagateThenTcDelayed cenv overallTy env tpenv mExpr expr exprty (atomicFla
| [] ->
// Avoid unifying twice: we're about to unify in TcDelayed
if not (isNil delayed) then
UnifyTypes cenv env mExpr overallTy exprty
UnifyTypesAndRecover cenv env mExpr overallTy exprty
| DelayedDot :: _
| DelayedSet _ :: _
| DelayedDotLookup _ :: _ -> ()
Expand All @@ -8108,7 +8116,7 @@ and PropagateThenTcDelayed cenv overallTy env tpenv mExpr expr exprty (atomicFla
| SynExpr.CompExpr _ -> ()
| _ ->
// 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed
error (NotAFunction(denv,overallTy,mExpr,mArg))

propagate delayed expr.Range exprty
Expand All @@ -8127,7 +8135,8 @@ and TcDelayed cenv overallTy env tpenv mExpr expr exprty (atomicFlag:ExprAtomicF
match delayed with
| []
| DelayedDot :: _ ->
UnifyTypes cenv env mExpr overallTy exprty; expr.Expr,tpenv
UnifyTypesAndRecover cenv env mExpr overallTy exprty
expr.Expr,tpenv
// expr.M(args) where x.M is a .NET method or index property
// expr.M<tyargs>(args) where x.M is a .NET method or index property
// expr.M where x.M is a .NET method or index property
Expand Down Expand Up @@ -8689,7 +8698,7 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution

| Item.CustomOperation (nm,usageTextOpt,_) ->
// 'delayed' is about to be dropped on the floor, first do rudimentary checking to get name resolutions in its body
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed
RecordNameAndTypeResolutions_IdeallyWithoutHavingOtherEffects_Delayed cenv env tpenv delayed
match usageTextOpt() with
| None -> error(Error(FSComp.SR.tcCustomOperationNotUsedCorrectly(nm), mItem))
| Some usageText -> error(Error(FSComp.SR.tcCustomOperationNotUsedCorrectly2(nm,usageText), mItem))
Expand Down
6 changes: 6 additions & 0 deletions tests/fsharp/typeProviders/negTests/neg1.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -1966,16 +1966,22 @@ neg1.fsx(438,109,438,110): typecheck error FS0001: This expression was expected
but here has type
'string'

neg1.fsx(438,9,438,111): typecheck error FS3033: The type provider 'Provider.GoodProviderForNegativeStaticParameterTypeTests' reported an error: Specified cast is not valid.

neg1.fsx(440,119,440,120): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
'string'

neg1.fsx(440,19,440,121): typecheck error FS3033: The type provider 'Provider.GoodProviderForNegativeStaticParameterTypeTests' reported an error: Specified cast is not valid.

neg1.fsx(440,119,440,120): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
'string'

neg1.fsx(440,19,440,121): typecheck error FS3033: The type provider 'Provider.GoodProviderForNegativeStaticParameterTypeTests' reported an error: Specified cast is not valid.

neg1.fsx(448,9,448,107): typecheck error FS3148: Too many static parameters. Expected at most 1 parameters, but got 2 unnamed and 0 named parameters.

neg1.fsx(449,105,449,110): typecheck error FS3083: The static parameter 'Count' has already been given a value
Expand Down
8 changes: 8 additions & 0 deletions tests/fsharp/typecheck/sigs/neg04.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ but given a
''g list -> 'h'
The type 'seq<'a>' does not match the type ''f list'

neg04.fs(47,49,47,51): typecheck error FS0784: This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope

neg04.fs(47,30,47,51): typecheck error FS0001: Type mismatch. Expecting a
'seq<'a> -> 'f'
but given a
''g list -> 'h'
The type 'seq<'a>' does not match the type ''f list'

neg04.fs(61,25,61,40): typecheck error FS0001: This expression was expected to have type
'ClassType1'
but here has type
Expand Down
20 changes: 20 additions & 0 deletions tests/fsharp/typecheck/sigs/neg20.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ neg20.fs(184,28,184,33): typecheck error FS0001: This expression was expected to
but here has type
'obj'

neg20.fs(184,28,184,33): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
'obj'

neg20.fs(184,34,184,39): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
'obj'

neg20.fs(184,34,184,39): typecheck error FS0001: This expression was expected to have type
'int'
but here has type
Expand Down Expand Up @@ -272,6 +282,16 @@ neg20.fs(190,28,190,33): typecheck error FS0001: This expression was expected to
but here has type
'obj'

neg20.fs(190,28,190,33): typecheck error FS0001: This expression was expected to have type
'string'
but here has type
'obj'

neg20.fs(190,34,190,39): typecheck error FS0001: This expression was expected to have type
'string'
but here has type
'obj'

neg20.fs(190,34,190,39): typecheck error FS0001: This expression was expected to have type
'string'
but here has type
Expand Down
12 changes: 12 additions & 0 deletions tests/fsharp/typecheck/sigs/neg22.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ but given a
'float<kg>'
The unit of measure 'm' does not match the unit of measure 'kg'

neg22.fs(17,22,17,29): typecheck error FS0001: Type mismatch. Expecting a
'float<m>'
but given a
'float<kg>'
The unit of measure 'm' does not match the unit of measure 'kg'

neg22.fs(17,20,17,29): typecheck error FS0001: Type mismatch. Expecting a
'float<m>'
but given a
'float<kg>'
The unit of measure 'm' does not match the unit of measure 'kg'

neg22.fs(28,12,28,18): typecheck error FS0957: The declared type parameters for this type extension do not match the declared type parameters on the original type 'LibGen<_>'

neg22.fs(40,12,40,18): typecheck error FS0957: The declared type parameters for this type extension do not match the declared type parameters on the original type 'LibGen<_>'
Expand Down
Loading