diff --git a/vlib/v/gen/x64/gen.v b/vlib/v/gen/x64/gen.v index fd3bf3008e..fd9f7f3723 100644 --- a/vlib/v/gen/x64/gen.v +++ b/vlib/v/gen/x64/gen.v @@ -602,12 +602,28 @@ fn (mut g Gen) assign_stmt(node ast.AssignStmt) { // `a := 1` | `a,b := 1,2` for i, ident in node.left { match node.right[0] { - ast.IntegerLiteral { g.allocate_var(ident.name, 4, it.val.int()) } - else {} + ast.IntegerLiteral { + g.allocate_var(ident.name, 4, it.val.int()) + } + ast.InfixExpr { + g.infix_expr(it) + g.allocate_var(ident.name, 4, 0) + } + else { + verror('assign_stmt unhandled expr') + } } } } +fn (mut g Gen) infix_expr(node ast.InfixExpr) { + println('infix expr op=$node.op') + match node.op { + .plus {} + else {} + } +} + fn (mut g Gen) if_expr(node ast.IfExpr) { branch := node.branches[0] infix_expr := branch.cond as ast.InfixExpr diff --git a/vlib/v/gen/x64/tests/if.vv b/vlib/v/gen/x64/tests/general.vv similarity index 73% rename from vlib/v/gen/x64/tests/if.vv rename to vlib/v/gen/x64/tests/general.vv index 8a4a1e00a1..50c71f208a 100644 --- a/vlib/v/gen/x64/tests/if.vv +++ b/vlib/v/gen/x64/tests/general.vv @@ -1,4 +1,4 @@ -fn test() { +fn if_test() { a := 1 if a == 1 { println('a == 1') @@ -47,8 +47,25 @@ fn args() { foo(2) } +/* +fn expr() { + println('===expr===') + a := 1 + b := 2 + c := a + b + println('c==') + if c == 0 { + println('0') + } + if c == 3 { + println('3') + } +} +*/ + fn main() { - test() + if_test() loop() args() + //expr() } diff --git a/vlib/v/gen/x64/tests/if.vv.out b/vlib/v/gen/x64/tests/general.vv.out similarity index 100% rename from vlib/v/gen/x64/tests/if.vv.out rename to vlib/v/gen/x64/tests/general.vv.out diff --git a/vlib/v/tests/inout/compiler_test.v b/vlib/v/tests/inout/compiler_test.v index c45be57bd2..00d80dcea2 100644 --- a/vlib/v/tests/inout/compiler_test.v +++ b/vlib/v/tests/inout/compiler_test.v @@ -37,6 +37,14 @@ fn test_all() { } expected = expected.trim_space().trim('\n').replace('\r\n', '\n') found := res.output.trim_space().trim('\n').replace('\r\n', '\n') + if expected.contains('V panic:') { + // panic include backtraces, so can't do char by char comparison + panic_msg := expected.find_between('V panic:', '\n').trim_space() + if found.contains('V panic:') && found.contains(panic_msg) { + println(term.green('OK (panic)')) + continue + } + } if expected != found { println(term.red('FAIL')) // println(x.output.limit(30)) @@ -48,8 +56,7 @@ fn test_all() { println(found) println('============\n') total_errors++ - } - else { + } else { println(term.green('OK')) } }