mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix bug with sum type
This commit is contained in:
parent
0bdf9bbf4f
commit
a214778b74
@ -51,6 +51,8 @@ fn (p mut Parser) bool_expression() string {
|
|||||||
expected = p.expected_type
|
expected = p.expected_type
|
||||||
}
|
}
|
||||||
if expected != typ && expected in p.table.sum_types { // TODO perf
|
if expected != typ && expected in p.table.sum_types { // TODO perf
|
||||||
|
T := p.table.find_type(typ)
|
||||||
|
if T.parent == expected {
|
||||||
//p.warn('SUM CAST exp=$expected typ=$typ p.exp=$p.expected_type')
|
//p.warn('SUM CAST exp=$expected typ=$typ p.exp=$p.expected_type')
|
||||||
p.cgen.set_placeholder(start_ph,
|
p.cgen.set_placeholder(start_ph,
|
||||||
//'/*SUM TYPE CAST*/($expected) { .obj = &($typ[]) { ')
|
//'/*SUM TYPE CAST*/($expected) { .obj = &($typ[]) { ')
|
||||||
@ -58,7 +60,7 @@ fn (p mut Parser) bool_expression() string {
|
|||||||
tt := typ.all_after('_') // TODO
|
tt := typ.all_after('_') // TODO
|
||||||
//p.gen('}, .typ = SumType_${tt} }')//${val}_type }')
|
//p.gen('}, .typ = SumType_${tt} }')//${val}_type }')
|
||||||
p.gen(', sizeof($typ) ), .typ = SumType_${tt} }')//${val}_type }')
|
p.gen(', sizeof($typ) ), .typ = SumType_${tt} }')//${val}_type }')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return typ
|
return typ
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user