1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: stop mangling reference names

This commit is contained in:
Kris Cherven 2020-04-16 01:28:41 -04:00 committed by GitHub
parent c3ddaf16ec
commit 332d52f459
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -453,7 +453,13 @@ fn (f mut Fmt) struct_decl(node ast.StructDecl) {
} }
fn (f &Fmt) type_to_str(t table.Type) string { fn (f &Fmt) type_to_str(t table.Type) string {
res := f.table.type_to_str(t) mut res := f.table.type_to_str(t)
// type_ptr => &type
if res.ends_with('_ptr') {
res = res[0 .. res.len-4]
start_pos := 2 * res.count('[]')
res = res[0 .. start_pos] + '&' + res[start_pos .. res.len]
}
return res.replace(f.cur_mod + '.', '') return res.replace(f.cur_mod + '.', '')
} }

View File

@ -0,0 +1,14 @@
const (
x = &Test{}
y = []&Test
z = &[]&Test
)
fn test_type_ptr() {
a := &Test{}
b := []&Test
c := &[]&Test
}
struct Test {
}