We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f9106a8 commit d23e70fCopy full SHA for d23e70f
2 files changed
vlib/v/gen/c/cgen.v
@@ -5115,8 +5115,13 @@ fn (mut g Gen) ident(node ast.Ident) {
5115
}
5116
5117
5118
- if node.obj.ct_type_var != .smartcast && node.obj.is_unwrapped {
5119
- g.write('.data')
+ if i == 0 && node.obj.ct_type_var != .smartcast && node.obj.is_unwrapped {
+ dot := if !node.obj.orig_type.is_ptr() && obj_sym.is_heap() {
5120
+ '->'
5121
+ } else {
5122
+ '.'
5123
+ }
5124
+ g.write('${dot}data')
5125
5126
g.write(')')
5127
vlib/v/tests/options/option_heap_var_test.v
@@ -0,0 +1,21 @@
1
+@[heap]
2
+struct Foo {
3
+ a int
4
+}
5
+
6
+struct EdgeService {
7
+ foo Foo
8
9
10
+fn t[S](s S) {
11
12
13
+fn test_main() {
14
+ mut svc := ?EdgeService(EdgeService{})
15
+ if svc != none {
16
+ t(svc)
17
+ assert true
18
19
+ assert false
20
21
0 commit comments