mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: add byte deprecation warning (#18287)
This commit is contained in:
parent
3ac63cce86
commit
1be539d20f
@ -702,6 +702,9 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
|
|||||||
&& right is ast.StructInit && (right as ast.StructInit).is_anon {
|
&& right is ast.StructInit && (right as ast.StructInit).is_anon {
|
||||||
c.error('cannot assign anonymous `struct` to a typed `struct`', right.pos())
|
c.error('cannot assign anonymous `struct` to a typed `struct`', right.pos())
|
||||||
}
|
}
|
||||||
|
if right_sym.kind == .alias && right_sym.name == 'byte' {
|
||||||
|
c.warn('byte is deprecated, use u8 instead', right.pos())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// this needs to run after the assign stmt left exprs have been run through checker
|
// this needs to run after the assign stmt left exprs have been run through checker
|
||||||
// so that ident.obj is set
|
// so that ident.obj is set
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
vlib/v/checker/tests/struct_type_cast_err.vv:10:7: warning: byte is deprecated, use u8 instead
|
||||||
|
8 | _ := u32(foo)
|
||||||
|
9 | _ := rune(foo)
|
||||||
|
10 | _ := byte(foo)
|
||||||
|
| ~~~~~~~~~
|
||||||
|
11 | _ := i8(foo)
|
||||||
|
12 | _ := i64(foo)
|
||||||
vlib/v/checker/tests/struct_type_cast_err.vv:5:7: error: cannot cast struct `Foo` to `string`
|
vlib/v/checker/tests/struct_type_cast_err.vv:5:7: error: cannot cast struct `Foo` to `string`
|
||||||
3 | fn main() {
|
3 | fn main() {
|
||||||
4 | foo := Foo{}
|
4 | foo := Foo{}
|
||||||
|
Loading…
Reference in New Issue
Block a user