gen: fix pointer_str_test.v

pull/4975/head
yuyi 2020-05-21 20:09:35 +08:00 committed by GitHub
parent 0de70e8b2c
commit 047e982318
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -8,7 +8,6 @@ const (
skip_test_files = [
'vlib/v/tests/enum_bitfield_test.v',
'vlib/v/tests/pointers_test.v',
'vlib/v/tests/pointers_str_test.v',
'vlib/net/http/http_httpbin_test.v',
]
skip_on_musl = [

View File

@ -364,13 +364,17 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
// g.write('/*${g.typ(node.receiver_type)}*/')
// g.write('/*expr_type=${g.typ(node.left_type)} rec type=${g.typ(node.receiver_type)}*/')
// }
g.write('${name}(')
if !node.receiver_type.is_ptr() && node.left_type.is_ptr() && node.name == 'str' {
g.write('ptr_str(')
} else {
g.write('${name}(')
}
if node.receiver_type.is_ptr() && !node.left_type.is_ptr() {
// The receiver is a reference, but the caller provided a value
// Add `&` automatically.
// TODO same logic in call_args()
g.write('&')
} else if !node.receiver_type.is_ptr() && node.left_type.is_ptr() {
} else if !node.receiver_type.is_ptr() && node.left_type.is_ptr() && node.name != 'str' {
g.write('/*rec*/*')
}
g.expr(node.left)