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

make the unused variable error a warning in non-production builds

This commit is contained in:
Alexander Medvednikov 2019-09-19 19:50:43 +03:00
parent b6bb6a5a60
commit 9a7fface7d

View File

@ -540,7 +540,11 @@ fn (p mut Parser) check_unused_variables() {
} }
if !var.is_used && !p.pref.is_repl && !var.is_arg && !p.pref.translated && var.name != '_' { if !var.is_used && !p.pref.is_repl && !var.is_arg && !p.pref.translated && var.name != '_' {
p.scanner.line_nr = var.line_nr - 1 p.scanner.line_nr = var.line_nr - 1
p.error('`$var.name` declared and not used') if p.pref.is_prod {
p.error('`$var.name` declared and not used')
} else {
p.warn('`$var.name` declared and not used')
}
} }
if !var.is_changed && var.is_mut && !p.pref.is_repl && if !var.is_changed && var.is_mut && !p.pref.is_repl &&
!p.pref.translated && var.name != '_' { !p.pref.translated && var.name != '_' {