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:
parent
c3ddaf16ec
commit
332d52f459
@ -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 + '.', '')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
vlib/v/fmt/tests/type_ptr_keep.vv
Normal file
14
vlib/v/fmt/tests/type_ptr_keep.vv
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
const (
|
||||||
|
x = &Test{}
|
||||||
|
y = []&Test
|
||||||
|
z = &[]&Test
|
||||||
|
)
|
||||||
|
|
||||||
|
fn test_type_ptr() {
|
||||||
|
a := &Test{}
|
||||||
|
b := []&Test
|
||||||
|
c := &[]&Test
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Test {
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user