mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: minor sum type fix
This commit is contained in:
parent
ac0b235d3a
commit
66adf7a6b9
@ -1014,7 +1014,7 @@ fn (g mut Gen) match_expr(node ast.MatchExpr) {
|
||||
match fe {
|
||||
ast.Type {
|
||||
it_type := g.typ(it.typ)
|
||||
g.writeln('$it_type* it = ($it_type*)tmp3.obj; // ST it')
|
||||
g.writeln('$it_type* it = ($it_type*)${tmp}.obj; // ST it')
|
||||
}
|
||||
else {
|
||||
verror('match sum type')
|
||||
|
@ -41,11 +41,11 @@ void println(string s) {
|
||||
void handle_expr(Expr e) {
|
||||
Expr tmp1 = e;
|
||||
if (tmp1.typ == _type_idx_IfExpr) {
|
||||
IfExpr* it = (IfExpr*)tmp3.obj; // ST it
|
||||
IfExpr* it = (IfExpr*)tmp1.obj; // ST it
|
||||
println(tos3("if"));
|
||||
}
|
||||
else if (tmp1.typ == _type_idx_IntegerLiteral) {
|
||||
IntegerLiteral* it = (IntegerLiteral*)tmp3.obj; // ST it
|
||||
IntegerLiteral* it = (IntegerLiteral*)tmp1.obj; // ST it
|
||||
println(tos3("integer"));
|
||||
}
|
||||
else {
|
||||
@ -62,5 +62,7 @@ int main() {
|
||||
user.name = tos3("bob");
|
||||
Option_int n = get_opt();
|
||||
int a = /*opt*/(*(int*)n.data) + 3;
|
||||
handle_expr((IfExpr){
|
||||
0});
|
||||
return 0;
|
||||
}
|
||||
|
@ -46,4 +46,5 @@ fn main() {
|
||||
return
|
||||
}
|
||||
a := n + 3
|
||||
handle_expr(IfExpr{})
|
||||
}
|
||||
|
@ -1620,7 +1620,7 @@ fn (p mut Parser) match_expr() ast.MatchExpr {
|
||||
}
|
||||
p.scope.register_var(ast.Var{
|
||||
name: 'it'
|
||||
typ: typ
|
||||
typ: table.type_to_ptr(typ)
|
||||
})
|
||||
// TODO
|
||||
if p.tok.kind == .comma {
|
||||
|
Loading…
Reference in New Issue
Block a user