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

[deprecated] attribute

This commit is contained in:
Alexander Medvednikov 2019-10-20 20:15:48 +03:00
parent 1b518c158b
commit c13b58e6db

View File

@ -32,6 +32,7 @@ mut:
returns_error bool returns_error bool
is_decl bool // type myfn fn(int, int) is_decl bool // type myfn fn(int, int)
is_unsafe bool is_unsafe bool
is_deprecated bool
defer_text []string defer_text []string
is_generic bool is_generic bool
type_pars []string type_pars []string
@ -187,6 +188,7 @@ fn (p mut Parser) fn_decl() {
mod: p.mod mod: p.mod
is_public: p.tok == .key_pub is_public: p.tok == .key_pub
is_unsafe: p.attr == 'unsafe_fn' is_unsafe: p.attr == 'unsafe_fn'
is_deprecated: p.attr == 'deprecated'
} }
is_live := p.attr == 'live' && !p.pref.is_so && p.pref.is_live is_live := p.attr == 'live' && !p.pref.is_so && p.pref.is_live
if p.attr == 'live' && p.first_pass() && !p.pref.is_live && !p.pref.is_so { if p.attr == 'live' && p.first_pass() && !p.pref.is_live && !p.pref.is_so {
@ -637,6 +639,9 @@ fn (p mut Parser) fn_call(f mut Fn, method_ph int, receiver_var, receiver_type s
if f.is_unsafe && !p.builtin_mod && !p.inside_unsafe { if f.is_unsafe && !p.builtin_mod && !p.inside_unsafe {
p.error('you are calling an unsafe function outside of an unsafe block') p.error('you are calling an unsafe function outside of an unsafe block')
} }
if f.is_deprecated {
p.warn('$f.name is deprecated')
}
if !f.is_public && !f.is_c && !p.pref.is_test && !f.is_interface && f.mod != p.mod { if !f.is_public && !f.is_c && !p.pref.is_test && !f.is_interface && f.mod != p.mod {
if f.name == 'contains' { if f.name == 'contains' {
println('use `value in numbers` instead of `numbers.contains(value)`') println('use `value in numbers` instead of `numbers.contains(value)`')