1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: stay silent about unused variables starting with _

This commit is contained in:
Delyan Angelov 2020-04-25 15:37:32 +03:00
parent aacc3c6f7e
commit 945f964c0c
2 changed files with 6 additions and 3 deletions

View File

@ -112,7 +112,7 @@ fn test_no_line_ending() {
mut row_count := 0 mut row_count := 0
for { for {
row := csv_reader.read() or { _row := csv_reader.read() or {
break break
} }
row_count++ row_count++

View File

@ -195,8 +195,11 @@ pub fn (mut p Parser) open_scope() {
} }
pub fn (mut p Parser) close_scope() { pub fn (mut p Parser) close_scope() {
if !p.pref.is_repl && !scanner.is_fmt { if !p.pref.is_repl && !p.scanner.is_fmt {
for v in p.scope.unused_vars() { for v in p.scope.unused_vars() {
if v.name.len > 0 && v.name[0]==`_` {
continue
}
if p.pref.is_prod { if p.pref.is_prod {
p.error_with_pos('Unused variable: $v.name', v.pos) p.error_with_pos('Unused variable: $v.name', v.pos)
} else { } else {