1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: implement direct cast for sum type

This commit is contained in:
joe-conigliaro
2020-01-04 00:42:48 +11:00
committed by Alexander Medvednikov
parent 520ec0f53a
commit 43895269ff
2 changed files with 19 additions and 4 deletions

View File

@ -28,12 +28,12 @@ struct BoolExpr {
}
struct BinExpr {
name string
}
fn expr1() Expr {
mut e := Expr{}
e = BinExpr{}
e = BinExpr{'binexpr'}
return e
//return BinExpr{}
}
@ -55,6 +55,12 @@ fn parse_bool() BoolExpr {
return BoolExpr{}
}
fn test_sum_type_cast() {
a := expr1()
b := a as BinExpr
assert b.name == 'binexpr'
}
fn test_sum_types() {
b := parse_bool()
handle_expr(b)