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:
parent
b6bb6a5a60
commit
9a7fface7d
@ -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 != '_' {
|
||||||
|
Loading…
Reference in New Issue
Block a user