From ade5774313f0d43c9722ffa9b4caf056ca462b8f Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 12 Oct 2021 18:38:17 +0200 Subject: [PATCH] native: fix return `a+b` infix construction (#12161) --- vlib/v/gen/native/amd64.v | 1 - vlib/v/gen/native/gen.v | 4 +--- vlib/v/gen/native/tests/sumcall.vv | 7 +++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/vlib/v/gen/native/amd64.v b/vlib/v/gen/native/amd64.v index 423f089bc3..63984b72af 100644 --- a/vlib/v/gen/native/amd64.v +++ b/vlib/v/gen/native/amd64.v @@ -777,7 +777,6 @@ pub fn (mut g Gen) call_fn(node ast.CallExpr) { if !n.contains('.') { n = 'main.$n' } - eprintln('call fn ($n)') addr := g.fn_addr[n] if addr == 0 { // g.warning('fn addr of `$name` = 0') diff --git a/vlib/v/gen/native/gen.v b/vlib/v/gen/native/gen.v index b18d72a57f..10cfcfb4d9 100644 --- a/vlib/v/gen/native/gen.v +++ b/vlib/v/gen/native/gen.v @@ -468,8 +468,7 @@ fn (mut g Gen) stmt(node ast.Stmt) { g.mov64(.rax, e0.val.int()) } ast.InfixExpr { - // TODO - // verror('expr') + g.infix_expr(e0) } ast.CastExpr { g.mov64(.rax, e0.expr.str().int()) @@ -482,7 +481,6 @@ fn (mut g Gen) stmt(node ast.Stmt) { } ast.Ident { g.expr(e0) - eprintln('ident $e0.name') } else { g.n_error('unknown return type $e0.type_name()') diff --git a/vlib/v/gen/native/tests/sumcall.vv b/vlib/v/gen/native/tests/sumcall.vv index b91f941c67..e1bf951f38 100644 --- a/vlib/v/gen/native/tests/sumcall.vv +++ b/vlib/v/gen/native/tests/sumcall.vv @@ -10,10 +10,9 @@ fn sumcall2(a int, b int) int { fn main() { r := sumcall (1,2) assert r == 3 -/* - // XXX not yet working + s := sumcall2 (1,2) - assert r == 3 -*/ + assert s == 3 + exit(0) }