mirror of
https://github.com/vlang/v.git
synced 2025-09-24 04:48:28 -04:00
cgen: fix wrong heap promoted arg detection (#20421)
This commit is contained in:
parent
1c11f13f28
commit
ab9aea2282
@ -628,6 +628,7 @@ fn (mut g Gen) fn_decl_params(params []ast.Param, scope &ast.Scope, is_variadic
|
|||||||
g.definitions.write_string(')')
|
g.definitions.write_string(')')
|
||||||
fparams << caname
|
fparams << caname
|
||||||
fparamtypes << param_type_name
|
fparamtypes << param_type_name
|
||||||
|
heap_promoted << false
|
||||||
} else {
|
} else {
|
||||||
mut heap_prom := false
|
mut heap_prom := false
|
||||||
if scope != unsafe { nil } {
|
if scope != unsafe { nil } {
|
||||||
|
17
vlib/v/tests/fn_heap_promoted_test.v
Normal file
17
vlib/v/tests/fn_heap_promoted_test.v
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
@[heap]
|
||||||
|
struct Context {}
|
||||||
|
|
||||||
|
type Method = fn (ctx Context)
|
||||||
|
|
||||||
|
fn call(method Method, ctx Context) { // or switch `ctx` and `method` also ok
|
||||||
|
method(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get(ctx Context) {
|
||||||
|
println('ok')
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_main() {
|
||||||
|
call(get, Context{})
|
||||||
|
assert true
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user