mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03: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
|
||||
cached_type_to_str map[u64]string
|
||||
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
|
||||
|
@ -91,7 +91,6 @@ mut:
|
||||
if_cond_comments []ast.Comment
|
||||
script_mode bool
|
||||
script_mode_start_token token.Token
|
||||
anon_struct_counter int
|
||||
pub mut:
|
||||
scanner &scanner.Scanner
|
||||
errors []errors.Error
|
||||
|
@ -41,8 +41,8 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
|
||||
return ast.StructDecl{}
|
||||
}
|
||||
mut name := if is_anon {
|
||||
p.anon_struct_counter++
|
||||
'_VAnonStruct$p.anon_struct_counter'
|
||||
p.table.anon_struct_counter++
|
||||
'_VAnonStruct$p.table.anon_struct_counter'
|
||||
} else {
|
||||
p.check_name()
|
||||
}
|
||||
|
@ -261,3 +261,7 @@ fn test_fn_is_html_open_tag() {
|
||||
b = is_html_open_tag('style', s)
|
||||
assert b == false
|
||||
}
|
||||
|
||||
// For issue #15516
|
||||
fn test_anon_struct() {
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user