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

all: promote value type function arguments to heap if necessary (#10528)

This commit is contained in:
Uwe Krüger
2021-06-20 17:40:24 +02:00
committed by GitHub
parent 6c8182cc25
commit f32a76b268
8 changed files with 130 additions and 35 deletions

View File

@@ -310,10 +310,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
scope: 0
}
}
mut is_stack_obj := true
if param.typ.has_flag(.shared_f) {
is_stack_obj = false
}
is_stack_obj := !param.typ.has_flag(.shared_f) && (param.is_mut || param.typ.is_ptr())
p.scope.register(ast.Var{
name: param.name
typ: param.typ
@@ -628,10 +625,7 @@ fn (mut p Parser) anon_fn() ast.AnonFn {
if arg.name.len == 0 {
p.error_with_pos('use `_` to name an unused parameter', arg.pos)
}
mut is_stack_obj := true
if arg.typ.has_flag(.shared_f) {
is_stack_obj = false
}
is_stack_obj := !arg.typ.has_flag(.shared_f) && (arg.is_mut || arg.typ.is_ptr())
p.scope.register(ast.Var{
name: arg.name
typ: arg.typ