Skip to content

Commit

Permalink
potential fix for #8
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyme committed Apr 9, 2015
1 parent c6ffdb6 commit 67d4d7f
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/fsharp/tc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3702,6 +3702,9 @@ type DelayedItem =
/// Represents the long identifiers in "item.Ident1", or "item.Ident1.Ident2" etc.
| DelayedDotLookup of Ast.Ident list * range

/// Represents an incomplete "item."
| DelayedDot

/// Represents the valueExpr in "item <- valueExpr", also "item.[indexerArgs] <- valueExpr" etc.
| DelayedSet of Ast.SynExpr * range

Expand Down Expand Up @@ -5099,6 +5102,22 @@ and TcExprNoRecover cenv ty (env: TcEnv) tpenv (expr: SynExpr) =

tm,tpenv

// This recursive entry is only used from one callsite (DiscardAfterMissingQualificationAfterDot)
// and has been added relatively late in F# 4.0 to preserve the structure of previous code. It pushes a 'delayed' parameter
// through TcExprOfUnknownType, TcExpr and TcExprNoRecover
and TcExprOfUnknownTypeThen cenv env tpenv expr delayed =
let exprty = NewInferenceType ()
let expr',tpenv =
try
TcExprThen cenv exprty env tpenv expr delayed
with e ->

// Error recovery - return some rubbish expression, but replace/annotate
// the type of the current expression with a type variable that indicates an error
errorRecovery e m
solveTypAsError cenv env.DisplayEnv m ty
mkThrow m ty (mkOne cenv.g m), tpenv
expr',exprty,tpenv

/// This is used to typecheck legitimate 'main body of constructor' expressions
and TcExprThatIsCtorBody safeInitInfo cenv overallTy env tpenv expr =
Expand Down Expand Up @@ -5454,10 +5473,9 @@ and TcExprUndelayed cenv overallTy env tpenv (expr: SynExpr) =
//solveTypAsError cenv env.DisplayEnv m overallTy
mkDefault(m,overallTy), tpenv

// expr. (already reported as an error)
| SynExpr.DiscardAfterMissingQualificationAfterDot (e1,m) ->
// For some reason we use "UnknownType" for this one, it's not clear we need to.
let _,_,tpenv = suppressErrorReporting (fun () -> TcExprOfUnknownType cenv env tpenv e1)
//solveTypAsError cenv env.DisplayEnv m overallTy
let _,_,tpenv = suppressErrorReporting (fun () -> TcExprOfUnknownTypeThen cenv env tpenv e1 [DelayedDot])
mkDefault(m,overallTy),tpenv

| SynExpr.FromParseError (e1,m) ->
Expand Down Expand Up @@ -7732,6 +7750,7 @@ and PropagateThenTcDelayed cenv overallTy env tpenv mExpr expr exprty (atomicFla
// Avoid unifying twice: we're about to unify in TcDelayed
if nonNil delayed then
UnifyTypes cenv env mExpr overallTy exprty
| DelayedDot :: _
| DelayedSet _ :: _
| DelayedDotLookup _ :: _ -> ()
| DelayedTypeApp (_, _mTypeArgs, mExprAndTypeArgs) :: delayedList' ->
Expand Down Expand Up @@ -7766,7 +7785,9 @@ and TcDelayed cenv overallTy env tpenv mExpr expr exprty (atomicFlag:ExprAtomicF
CallExprHasTypeSink cenv.tcSink (mExpr,env.NameEnv,exprty, env.DisplayEnv,env.eAccessRights)

match delayed with
| [] -> UnifyTypes cenv env mExpr overallTy exprty; expr.Expr,tpenv
| []
| DelayedDot :: _ ->
UnifyTypes 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 @@ -7844,7 +7865,7 @@ and TcLongIdentThen cenv overallTy env tpenv (LongIdentWithDots(longId,_)) delay
// resolve type name lookup of 'MyOverloadedType'
// Also determine if type names should resolve to Item.Types or Item.CtorGroup
match delayed with
| DelayedTypeApp (tyargs, _, _) :: DelayedDotLookup _ :: _ ->
| DelayedTypeApp (tyargs, _, _) :: (DelayedDot | DelayedDotLookup _) :: _ ->
// cases like 'MyType<int>.Sth'
TypeNameResolutionInfo(ResolveTypeNamesToTypeRefs, TypeNameResolutionStaticArgsInfo.FromTyArgs tyargs.Length)

Expand Down

0 comments on commit 67d4d7f

Please sign in to comment.