mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
ast: return cached_name.clone(), as auto_str_methods free it (#25088)
This commit is contained in:
parent
ec29f43a4d
commit
d5458b58eb
1 changed files with 7 additions and 7 deletions
|
@ -400,7 +400,7 @@ __global nested_expr_str_calls = i64(0)
|
|||
const max_nested_expr_str_calls = 300
|
||||
|
||||
// string representation of expr
|
||||
pub fn (x &Expr) str() string {
|
||||
pub fn (x Expr) str() string {
|
||||
str_calls := stdatomic.add_i64(&nested_expr_str_calls, 1)
|
||||
if str_calls > max_nested_expr_str_calls {
|
||||
$if panic_on_deeply_nested_expr_str_calls ? {
|
||||
|
@ -525,13 +525,13 @@ pub fn (x &Expr) str() string {
|
|||
return 'spawn ${x.call_expr}'
|
||||
}
|
||||
Ident {
|
||||
if x.cached_name != '' {
|
||||
return x.cached_name
|
||||
if x.cached_name == '' {
|
||||
unsafe {
|
||||
x.cached_name = util.strip_main_name(x.name)
|
||||
}
|
||||
}
|
||||
unsafe {
|
||||
x.cached_name = util.strip_main_name(x.name.clone())
|
||||
}
|
||||
return x.cached_name
|
||||
// This clone may freed by auto str()
|
||||
return x.cached_name.clone()
|
||||
}
|
||||
IfExpr {
|
||||
mut parts := []string{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue