Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Sep 23, 2024
1 parent 4f39bac commit 7c7664e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -4375,7 +4375,7 @@ fn (mut c Checker) mark_as_referenced(mut node ast.Expr, as_interface bool) {
node.obj.is_auto_heap = true
}
}
.sum_type, .interface_ {}
.sum_type, .interface_, .function {}
else {
node.obj.is_auto_heap = true
}
Expand Down
20 changes: 20 additions & 0 deletions vlib/v/tests/pointers/ref_callback_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module main

struct Struct_voidptr {
func voidptr
}

fn function() string {
return 'Function!'
}

fn test_main() {
fun := function

sct := Struct_voidptr{
func: &fun
}

assert fun() == 'Function!'
assert sct.func == &fun
}

0 comments on commit 7c7664e

Please sign in to comment.