Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update tests
  • Loading branch information
dsyme committed Feb 28, 2019
commit 0784a7f72ced2c129e6787ab8052b35ee0de2e3f
59 changes: 47 additions & 12 deletions src/fsharp/FindUnsolved.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,46 +38,65 @@ let rec accExpr (cenv:cenv) (env:env) expr =
| Expr.Sequential (e1,e2,_,_,_) ->
accExpr cenv env e1
accExpr cenv env e2

| Expr.Let (bind,body,_,_) ->
accBind cenv env bind
accExpr cenv env body

| Expr.Const (_,_,ty) ->
accTy cenv env ty

| Expr.Val (_v,_vFlags,_m) -> ()

| Expr.Quote(ast,_,_,_m,ty) ->
accExpr cenv env ast
accTy cenv env ty

| Expr.Obj (_,ty,basev,basecall,overrides,iimpls,_m) ->
accTy cenv env ty
accExpr cenv env basecall
accMethods cenv env basev overrides
accIntfImpls cenv env basev iimpls

| LinearOpExpr (_op, tyargs, argsHead, argLast, _m) ->
// Note, LinearOpExpr doesn't include any of the "special" cases for accOp
accTypeInst cenv env tyargs
accExprs cenv env argsHead
// tailcall
accExpr cenv env argLast

| Expr.Op (c,tyargs,args,m) ->
accOp cenv env (c,tyargs,args,m)

| Expr.App(f,fty,tyargs,argsl,_m) ->
accTy cenv env fty
accTypeInst cenv env tyargs
accExpr cenv env f
accExprs cenv env argsl

| Expr.Lambda(_,_ctorThisValOpt,_baseValOpt,argvs,_body,m,rty) ->
let topValInfo = ValReprInfo ([],[argvs |> List.map (fun _ -> ValReprInfo.unnamedTopArg1)],ValReprInfo.unnamedRetVal)
let ty = mkMultiLambdaTy m argvs rty
accLambdas cenv env topValInfo expr ty

| Expr.TyLambda(_,tps,_body,_m,rty) ->
let topValInfo = ValReprInfo (ValReprInfo.InferTyparInfo tps,[],ValReprInfo.unnamedRetVal)
accTy cenv env rty
let ty = mkForallTyIfNeeded tps rty
accLambdas cenv env topValInfo expr ty

| Expr.TyChoose(_tps,e1,_m) ->
accExpr cenv env e1

| Expr.Match(_,_exprm,dtree,targets,m,ty) ->
accTy cenv env ty
accDTree cenv env dtree
accTargets cenv env m ty targets

| Expr.LetRec (binds,e,_m,_) ->
accBinds cenv env binds
accExpr cenv env e

| Expr.StaticOptimization (constraints,e2,e3,_m) ->
accExpr cenv env e2
accExpr cenv env e3
Expand All @@ -87,14 +106,19 @@ let rec accExpr (cenv:cenv) (env:env) expr =
accTy cenv env ty2
| TTyconIsStruct(ty1) ->
accTy cenv env ty1)

| Expr.Link _eref -> failwith "Unexpected reclink"

and accMethods cenv env baseValOpt l = List.iter (accMethod cenv env baseValOpt) l
and accMethods cenv env baseValOpt l =
List.iter (accMethod cenv env baseValOpt) l

and accMethod cenv env _baseValOpt (TObjExprMethod(_slotsig,_attribs,_tps,vs,e,_m)) =
vs |> List.iterSquared (accVal cenv env)
accExpr cenv env e

and accIntfImpls cenv env baseValOpt l = List.iter (accIntfImpl cenv env baseValOpt) l
and accIntfImpls cenv env baseValOpt l =
List.iter (accIntfImpl cenv env baseValOpt) l

and accIntfImpl cenv env baseValOpt (ty,overrides) =
accTy cenv env ty
accMethods cenv env baseValOpt overrides
Expand Down Expand Up @@ -132,11 +156,14 @@ and accLambdas cenv env topValInfo e ety =
| _ ->
accExpr cenv env e

and accExprs cenv env exprs = exprs |> List.iter (accExpr cenv env)
and accExprs cenv env exprs =
exprs |> List.iter (accExpr cenv env)

and accTargets cenv env m ty targets = Array.iter (accTarget cenv env m ty) targets
and accTargets cenv env m ty targets =
Array.iter (accTarget cenv env m ty) targets

and accTarget cenv env _m _ty (TTarget(_vs,e,_)) = accExpr cenv env e
and accTarget cenv env _m _ty (TTarget(_vs,e,_)) =
accExpr cenv env e

and accDTree cenv env x =
match x with
Expand Down Expand Up @@ -169,7 +196,8 @@ and accAttrib cenv env (Attrib(_,_k,args,props,_,_,_m)) =
accExpr cenv env expr2
accTy cenv env ty)

and accAttribs cenv env attribs = List.iter (accAttrib cenv env) attribs
and accAttribs cenv env attribs =
List.iter (accAttrib cenv env) attribs

and accValReprInfo cenv env (ValReprInfo(_,args,ret)) =
args |> List.iterSquared (accArgReprInfo cenv env)
Expand All @@ -188,7 +216,8 @@ and accBind cenv env (bind:Binding) =
let topValInfo = match bind.Var.ValReprInfo with Some info -> info | _ -> ValReprInfo.emptyValData
accLambdas cenv env topValInfo bind.Expr bind.Var.Type

and accBinds cenv env xs = xs |> List.iter (accBind cenv env)
and accBinds cenv env xs =
xs |> List.iter (accBind cenv env)

let accTyconRecdField cenv env _tycon (rfield:RecdField) =
accAttribs cenv env rfield.PropertyAttribs
Expand All @@ -203,13 +232,15 @@ let accTycon cenv env (tycon:Tycon) =
accAttribs cenv env uc.Attribs
uc.RecdFieldsArray |> Array.iter (accTyconRecdField cenv env tycon))

let accTycons cenv env tycons = List.iter (accTycon cenv env) tycons
let accTycons cenv env tycons =
List.iter (accTycon cenv env) tycons

let rec accModuleOrNamespaceExpr cenv env x =
match x with
| ModuleOrNamespaceExprWithSig(_mty, def, _m) -> accModuleOrNamespaceDef cenv env def

and accModuleOrNamespaceDefs cenv env x = List.iter (accModuleOrNamespaceDef cenv env) x
and accModuleOrNamespaceDefs cenv env x =
List.iter (accModuleOrNamespaceDef cenv env) x

and accModuleOrNamespaceDef cenv env x =
match x with
Expand All @@ -221,12 +252,16 @@ and accModuleOrNamespaceDef cenv env x =
| TMAbstract(def) -> accModuleOrNamespaceExpr cenv env def
| TMDefs(defs) -> accModuleOrNamespaceDefs cenv env defs

and accModuleOrNamespaceBinds cenv env xs = List.iter (accModuleOrNamespaceBind cenv env) xs
and accModuleOrNamespaceBinds cenv env xs =
List.iter (accModuleOrNamespaceBind cenv env) xs

and accModuleOrNamespaceBind cenv env x =
match x with
| ModuleOrNamespaceBinding.Binding bind -> accBind cenv env bind
| ModuleOrNamespaceBinding.Module(mspec, rhs) -> accTycon cenv env mspec; accModuleOrNamespaceDef cenv env rhs
| ModuleOrNamespaceBinding.Binding bind ->
accBind cenv env bind
| ModuleOrNamespaceBinding.Module(mspec, rhs) ->
accTycon cenv env mspec
accModuleOrNamespaceDef cenv env rhs

let UnsolvedTyparsOfModuleDef g amap denv (mdef, extraAttribs) =
let cenv =
Expand Down
4 changes: 2 additions & 2 deletions src/fsharp/PostInferenceChecks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ and CheckCallWithReceiver cenv env m returnTy args contexts context =
limitArgs
CheckCallLimitArgs cenv env m returnTy limitArgs context

and CheckExprLinear (cenv:cenv) (env:env) expr (context:PermitByRefExpr) contf =
and CheckExprLinear (cenv:cenv) (env:env) expr (context:PermitByRefExpr) (contf : Limit -> Limit) =
match expr with
| Expr.Sequential (e1,e2,NormalSeq,_,_) ->
CheckExprNoByrefs cenv env e1
Expand All @@ -905,7 +905,7 @@ and CheckExprLinear (cenv:cenv) (env:env) expr (context:PermitByRefExpr) contf =
CheckTypeInstNoByrefs cenv env m tyargs
argsHead |> List.iter (CheckExprNoByrefs cenv env)
// tailcall
CheckExprLinear cenv env argLast PermitByRefExpr.No (fun _ -> NoLimit)
CheckExprLinear cenv env argLast PermitByRefExpr.No (fun _ -> contf NoLimit)

| LinearMatchExpr (_spMatch, _exprm, dtree, tg1, e2, _spTarget2, m, ty) ->
CheckTypeNoInnerByrefs cenv env m ty
Expand Down
12 changes: 11 additions & 1 deletion src/fsharp/TastOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6157,8 +6157,16 @@ type ExprFolders<'State> (folders : ExprFolder<'State>) =

and exprNoInterceptF (z: 'State) (x: Expr) =
match x with

| Expr.Const _ -> z

| Expr.Val _ -> z

| LinearOpExpr (_op, _tyargs, argsHead, argLast, _m) ->
let z = exprsF z argsHead
// tailcall
exprF z argLast

| Expr.Op (_c, _tyargs, args, _) ->
exprsF z args

Expand Down Expand Up @@ -6191,7 +6199,9 @@ type ExprFolders<'State> (folders : ExprFolder<'State>) =

| Expr.Match (_spBind, _exprm, dtree, targets, _m, _ty) ->
let z = dtreeF z dtree
Array.fold targetF z targets
let z = Array.fold targetF z targets.[0..targets.Length - 2]
// tailcall
targetF z targets.[targets.Length - 1]

| Expr.Quote(e, {contents=Some(_typeDefs, _argTypes, argExprs, _)}, _, _, _) ->
let z = exprF z e
Expand Down
2 changes: 2 additions & 0 deletions tests/fsharp/core/large/conditionals/LargeConditionals-200.fs
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,5 @@ let expectedValues() =
if rnd.Next(3) = 1 then 1 else
if rnd.Next(3) = 1 then 1 else
4
printfn "expectedValues() = %A" (expectedValues())
System.IO.File.WriteAllLines("test.ok", ["ok"])
2 changes: 2 additions & 0 deletions tests/fsharp/core/large/lets/LargeLets-500.fs
Original file line number Diff line number Diff line change
Expand Up @@ -505,3 +505,5 @@ let expectedValues() =
let x = x + rnd.Next(3)
let x = x + rnd.Next(3)
x
printfn "expectedValues() = %A" (expectedValues())
System.IO.File.WriteAllLines("test.ok", ["ok"])
Loading