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

pull/2047/head
Alexander Medvednikov 2019-09-19 19:50:43 +03:00
parent b6bb6a5a60
commit 9a7fface7d
1 changed files with 5 additions and 1 deletions

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
if p.pref.is_prod {
p.error('`$var.name` declared and not used') 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 != '_' {