Skip to content

Commit

Permalink
add a test case for pattern matching an empty variant type
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbarabash committed Jul 28, 2024
1 parent 923fa97 commit 6aef0fc
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Escalier.TypeChecker.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,46 @@ let InferEnumPatternMatching () =
printfn "result = %A" result
Assert.False(Result.isError result)

[<Fact>]
let InferGenericEnumPatternMatching () =
let result =
result {
let src =
"""
enum Option<T> {
Some[T],
None,
}
declare let value: Option<number>;
let x = match value {
Option.Some[value] => value,
Option.None => 0,
};
"""

let! ctx, env = inferModule src

Assert.Empty(ctx.Report.Diagnostics)

let! enumType =
env.GetScheme(QualifiedIdent.Ident "Option")
|> Result.mapError CompileError.TypeError

printfn $"enumType = {enumType}"

Assert.Type(
env,
"Option",
"<T>({readonly __TAG__: unique symbol} & [T] | {readonly __TAG__: unique symbol})"
)

Assert.Value(env, "x", "number")
}

printfn "result = %A" result
Assert.False(Result.isError result)

[<Fact>]
let InferIfLet () =
let result =
Expand Down

0 comments on commit 6aef0fc

Please sign in to comment.