Skip to content

v.parser crash when compile struct with c.xx field name #24279

Description

@kbkpbot

Describe the bug

when use v.parser parse a file, which has struct with c.xx fields name, it will crash

Reproduction Steps

parse.v

module main

import v.parser
import v.ast
import v.pref

fn main() {
	mut pref_ := pref.new_preferences()
	pref_.output_mode = .silent
	mut table := ast.new_table()
	parser.parse_file('parse_bug.v', mut table, .parse_comments, pref_)
}

parse_bug.v

struct MyStruct { 
	c.close int
}
v run parse.v

Expected Behavior

It should not crash

Current Behavior

$ v run parse.v
V panic: table.sym: invalid type (typ=ast.Type(0x0 = 0) idx=0). Compiler bug. This should never happen. Please report the bug using `v bug file.v`.

v hash: 188d68d
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:15497: at _v_panic: Backtrace
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:25299: by v__ast__default_table_panic_handler
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:25305: by v__ast__Table_panic
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:25424: by v__ast__Table_sym
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:41489: by v__parser__Parser_struct_decl
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:37633: by v__parser__Parser_top_stmt
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:37239: by v__parser__Parser_parse
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:37202: by v__parser__parse_file
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:42629: by main__main
/tmp/v_1000/parse.01JSAVZJHW9P91J5Z3X49ZET2Q.tmp.c:43065: by main

Possible Solution

No response

Additional Information/Context

parse.v is extracted from vlib/v/parser/v_parser_test.v
parse_bug.v is extracted from some project files translated by c2v.

V version

V 0.4.10 188d68d.188d68d

Environment details (OS name and version, etc.)

V full version V 0.4.10 188d68d.188d68d
OS linux, Ubuntu 24.04.2 LTS
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
Memory 1.79GB/15.51GB
V executable /media/HD/github/kbkpbot/v/v
V last modified time 2025-04-21 00:29:08
V home dir OK, value: /media/HD/github/kbkpbot/v
VMODULES OK, value: /home/mars/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /media/HD/github/kbkpbot/v
Git version git version 2.43.0
V git status weekly.2025.16-18-g188d68d3-dirty
.git/config present true
cc version cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
gcc version gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
clang version Ubuntu clang version 18.1.3 (1ubuntu1)
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.39-0ubuntu8.4) 2.39

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.Unit: ParserBugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions