Skip to content

Instantly share code, notes, and snippets.

View forki's full-sized avatar

Steffen Forkmann forki

View GitHub Profile
| ConstraintSolverTypesNotInEqualityRelation(denv,t1,t2,m,m2,contextInfo) ->
let t1, t2, _cxs = NicePrint.minimalStringsOfTwoTypes denv t1 t2
match contextInfo with
| ContextInfo.ElseBranchResult range when range = m ->
os.Append(FSComp.SR.elseBranchHasWrongType(t1,t2)) |> ignore
| _ -> os.Append(ConstraintSolverTypesNotInEqualityRelation2E().Format t1 t2) |> ignore
let env = { env with eContextInfo = ContextInfo.ElseBranchResult e3.Range }
let e3',tpenv = TcExprThatCanBeCtorBody cenv overallTy env tpenv e3
e3',SequencePointAtTarget,tpenv
[<RequireQualifiedAccess>]
/// Information about the context of a type equation.
type ContextInfo =
/// No context was given.
| NoContext
/// The type equation comes from a type check of the result of an else branch.
| ElseBranchResult of range
| ...
let tempTy = NewInferenceType ()
let e3',tpenv = TcExprThatCanBeCtorBody cenv tempTy env tpenv e3
let env = { env with eContextInfo = ContextInfo.ElseBranch }
UnifyTypes cenv env e3.Range overallTy tempty
| SynExpr.IfThenElse (e1,e2,e3opt,spIfToThen,isRecovery,mIfToThen,m) ->
let e1',tpenv = TcExprThatCantBeCtorBody cenv cenv.g.bool_ty env tpenv e1
let e2',tpenv =
if not isRecovery && Option.isNone e3opt then
let env = { env with eContextInfo = ContextInfo.OmittedElseBranch }
UnifyTypes cenv env m cenv.g.unit_ty overallTy
TcExprThatCanBeCtorBody cenv overallTy env tpenv e2
else
TcExprThatCanBeCtorBody cenv overallTy env tpenv e2
let e3',sp2,tpenv =
@forki
forki / WrongTypeInElse2.fs
Created November 28, 2016 12:27
Wrong type in else branch 2
let test = 100
let f x = printfn "%s" x
let y =
if test > 10 then "test"
else
f 123
"test"
@forki
forki / WrongTypeInElse.fs
Created November 28, 2016 11:00
wrong type in else
let test = 100
let y =
if test > 10 then "test"
else 123
div []
[for i in 0 .. model.Length-1 ->
div
[]
[ for j in 0 .. model.Length-1 ->
input
[ maxlength 1
property "value"
(match model.[i].[j] with
| 0 -> unbox ""
open System.Collections.Generic
type Box = int
type Sudoku = Box array array
let rows = id
let cols (sudoku:Sudoku) =
sudoku
|> Array.mapi (fun a row -> row |> Array.mapi (fun b cell -> sudoku.[b].[a]))
type Table<'a> = 'a[]
let getKey<'a> = "models/" + typeof<'a>.FullName