mirror of
https://github.com/vlang/v.git
synced 2025-09-15 10:27:19 -04:00
ci,ast: fix errors with -fsanitize=thread after 7d81633
This commit is contained in:
parent
fdc3a9c11c
commit
0117c7f30b
@ -8,6 +8,7 @@ import v.token
|
||||
import v.errors
|
||||
import v.util
|
||||
import v.pref
|
||||
import sync.stdatomic
|
||||
|
||||
pub type TypeDecl = AliasTypeDecl | FnTypeDecl | SumTypeDecl
|
||||
|
||||
@ -2095,25 +2096,25 @@ pub fn (expr Expr) is_blank_ident() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
__global nested_expr_pos_calls = 0
|
||||
__global nested_expr_pos_calls = i64(0)
|
||||
// values above 14000 risk stack overflow by default on macos in Expr.pos() calls
|
||||
const max_nested_expr_pos_calls = 5000
|
||||
|
||||
pub fn (expr Expr) pos() token.Pos {
|
||||
// all uncommented have to be implemented
|
||||
// Note: please do not print here. the language server will hang
|
||||
// as it uses STDIO primarily to communicate ~Ned
|
||||
nested_expr_pos_calls++
|
||||
if nested_expr_pos_calls > ast.max_nested_expr_pos_calls {
|
||||
pos_calls := stdatomic.add_i64(&nested_expr_pos_calls, 1)
|
||||
if pos_calls > ast.max_nested_expr_pos_calls {
|
||||
$if panic_on_deeply_nested_expr_pos_calls ? {
|
||||
eprintln('${@LOCATION}: too many nested Expr.pos() calls: ${nested_expr_pos_calls}, expr type: ${expr.type_name()}')
|
||||
eprintln('${@LOCATION}: too many nested Expr.pos() calls: ${pos_calls}, expr type: ${expr.type_name()}')
|
||||
exit(1)
|
||||
}
|
||||
return token.Pos{}
|
||||
}
|
||||
defer {
|
||||
nested_expr_pos_calls--
|
||||
stdatomic.sub_i64(&nested_expr_pos_calls, 1)
|
||||
}
|
||||
// all uncommented have to be implemented
|
||||
// Note: please do not print here. the language server will hang
|
||||
// as it uses STDIO primarily to communicate ~Ned
|
||||
return match expr {
|
||||
AnonFn {
|
||||
expr.decl.pos
|
||||
|
Loading…
x
Reference in New Issue
Block a user