Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyme authored and dsyme committed Nov 27, 2016
2 parents 6796ead + f67db1f commit 1cb58c6
Show file tree
Hide file tree
Showing 19 changed files with 662 additions and 282 deletions.
21 changes: 15 additions & 6 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3911,7 +3911,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 @@ -5328,7 +5328,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 @@ -8094,7 +8102,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 @@ -8113,7 +8121,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 @@ -8132,7 +8140,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 @@ -8694,7 +8703,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
40 changes: 25 additions & 15 deletions src/fsharp/vs/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ type TypeCheckInfo
| None, _ -> [], None
| Some(origLongIdent), Some _ -> origLongIdent, None
| Some(origLongIdent), None ->
assert (not (isNil origLongIdent))
System.Diagnostics.Debug.Assert(not (isNil origLongIdent), "origLongIdent is empty")
// note: as above, this happens when we are called for "precise" resolution - (F1 keyword, data tip etc..)
let plid, residue = List.frontAndBack origLongIdent
plid, Some residue
Expand Down Expand Up @@ -1370,20 +1370,30 @@ type TypeCheckInfo

// Not, this does not have to be a SyncOp, it can be called from any thread
member scope.GetExtraColorizations() =
[| for cnr in sResolutions.CapturedNameResolutions do
match cnr with
// 'seq' in 'seq { ... }' gets colored as keywords
| CNR(_, (Item.Value vref), ItemOccurence.Use, _, _, _, m) when valRefEq g g.seq_vref vref ->
yield (m, FSharpTokenColorKind.Keyword)
// custom builders, custom operations get colored as keywords
| CNR(_, (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use, _, _, _, m) ->
yield (m, FSharpTokenColorKind.Keyword)
// types get colored as types when they occur in syntactic types or custom attributes
// typevariables get colored as types when they occur in syntactic types custom builders, custom operations get colored as keywords
| CNR(_, (Item.TypeVar _ | Item.Types _ | Item.UnqualifiedType _) , (ItemOccurence.UseInType | ItemOccurence.UseInAttribute), _, _, _, m) ->
yield (m, FSharpTokenColorKind.TypeName)
| _ -> ()
|]
sResolutions.CapturedNameResolutions
|> Seq.choose (fun cnr ->
match cnr with
// 'seq' in 'seq { ... }' gets colored as keywords
| CNR(_, (Item.Value vref), ItemOccurence.Use, _, _, _, m) when valRefEq g g.seq_vref vref ->
Some (m, FSharpTokenColorKind.Keyword)
// custom builders, custom operations get colored as keywords
| CNR(_, (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use, _, _, _, m) ->
Some (m, FSharpTokenColorKind.Keyword)
// types get colored as types when they occur in syntactic types or custom attributes
// typevariables get colored as types when they occur in syntactic types custom builders, custom operations get colored as keywords
| CNR(_, ( Item.TypeVar _
| Item.Types _
| Item.UnqualifiedType _
| Item.CtorGroup _),
( ItemOccurence.UseInType
| ItemOccurence.UseInAttribute
| ItemOccurence.Use _
| ItemOccurence.Binding _
| ItemOccurence.Pattern _), _, _, _, m) ->
Some (m, FSharpTokenColorKind.TypeName)
| _ -> None)
|> Seq.toArray

member x.ScopeResolutions = sResolutions
member x.ScopeSymbolUses = sSymbolUses
member x.TcGlobals = g
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

0 comments on commit 1cb58c6

Please sign in to comment.