Skip to content

Commit

Permalink
parser: fix parsing of cgen.v, in normal mode, when the table is empt…
Browse files Browse the repository at this point in the history
…y (no files in `builtin` are preparsed) (fix #20606) (#20611)
  • Loading branch information
Lycs-D committed Feb 13, 2024
1 parent ec21663 commit 36470fe
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/parser/parser.v
Expand Up @@ -2218,7 +2218,7 @@ fn (mut p Parser) parse_multi_expr(is_top_level bool) ast.Stmt {
} else if !p.pref.translated && !p.is_translated && !p.pref.is_fmt && !p.pref.is_vet
&& tok.kind !in [.key_if, .key_match, .key_lock, .key_rlock, .key_select] {
for node in left {
if (is_top_level || p.tok.kind != .rcbr)
if (is_top_level || p.tok.kind !in [.comment, .rcbr])
&& node !in [ast.CallExpr, ast.PostfixExpr, ast.ComptimeCall, ast.SelectorExpr, ast.DumpExpr] {
is_complex_infix_expr := node is ast.InfixExpr
&& node.op in [.left_shift, .right_shift, .unsigned_right_shift, .arrow]
Expand Down
37 changes: 37 additions & 0 deletions vlib/v/parser/v_parser_test.v
Expand Up @@ -6,6 +6,7 @@ import v.gen.c
import v.checker
import v.pref
import term
import os

fn test_eval() {
/*
Expand Down Expand Up @@ -264,6 +265,42 @@ fn test_fn_is_html_open_tag() {
assert b == false
}

fn scan_v(mut files []string, path string) ! {
for i in os.ls(path)! {
p := os.join_path(path, i)
if os.is_file(p) {
if i.ends_with('.v') && !i.contains_any_substr(['_test.', 'test_', 'tests_']) {
files << p
}
} else {
if !i.starts_with('test') && !i.ends_with('_tests') && !i.ends_with('builtin') {
scan_v(mut files, p)!
}
}
}
}

fn parse(output_mode pref.OutputMode) ! {
mut pref_ := pref.new_preferences()
pref_.output_mode = output_mode
mut files := []string{}
scan_v(mut files, pref_.vlib)!
scan_v(mut files, os.join_path(pref_.vroot, 'cmd'))!
for f in files {
table := ast.new_table()
p := parse_file(f, table, .parse_comments, pref_)
assert isnil(p) == false
}
}

fn test_parse_with_silent() {
parse(.silent)!
}

fn test_parse_with_stdout() {
parse(.stdout)!
}

// For issue #15516
fn test_anon_struct() {
}

0 comments on commit 36470fe

Please sign in to comment.