mirror of
https://github.com/vlang/v.git
synced 2025-09-10 07:47:20 -04:00
parser: fix anon struct name conflict (#15517)
This commit is contained in:
parent
3eb6ad7b8c
commit
c10c8ff9e4
@ -47,6 +47,8 @@ pub mut:
|
|||||||
// cache for type_to_str_using_aliases
|
// cache for type_to_str_using_aliases
|
||||||
cached_type_to_str map[u64]string
|
cached_type_to_str map[u64]string
|
||||||
anon_struct_names map[string]int // anon struct name -> struct sym idx
|
anon_struct_names map[string]int // anon struct name -> struct sym idx
|
||||||
|
// counter for anon struct, avoid name conflicts.
|
||||||
|
anon_struct_counter int
|
||||||
}
|
}
|
||||||
|
|
||||||
// used by vls to avoid leaks
|
// used by vls to avoid leaks
|
||||||
|
@ -91,7 +91,6 @@ mut:
|
|||||||
if_cond_comments []ast.Comment
|
if_cond_comments []ast.Comment
|
||||||
script_mode bool
|
script_mode bool
|
||||||
script_mode_start_token token.Token
|
script_mode_start_token token.Token
|
||||||
anon_struct_counter int
|
|
||||||
pub mut:
|
pub mut:
|
||||||
scanner &scanner.Scanner
|
scanner &scanner.Scanner
|
||||||
errors []errors.Error
|
errors []errors.Error
|
||||||
|
@ -41,8 +41,8 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
|
|||||||
return ast.StructDecl{}
|
return ast.StructDecl{}
|
||||||
}
|
}
|
||||||
mut name := if is_anon {
|
mut name := if is_anon {
|
||||||
p.anon_struct_counter++
|
p.table.anon_struct_counter++
|
||||||
'_VAnonStruct$p.anon_struct_counter'
|
'_VAnonStruct$p.table.anon_struct_counter'
|
||||||
} else {
|
} else {
|
||||||
p.check_name()
|
p.check_name()
|
||||||
}
|
}
|
||||||
|
@ -261,3 +261,7 @@ fn test_fn_is_html_open_tag() {
|
|||||||
b = is_html_open_tag('style', s)
|
b = is_html_open_tag('style', s)
|
||||||
assert b == false
|
assert b == false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For issue #15516
|
||||||
|
fn test_anon_struct() {
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user