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:

committed by
Alexander Medvednikov

parent
520ec0f53a
commit
43895269ff
@ -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)
|
||||
|
Reference in New Issue
Block a user