diff --git a/vlib/v/checker/assign.v b/vlib/v/checker/assign.v index d37f3d8852..511844ca6e 100644 --- a/vlib/v/checker/assign.v +++ b/vlib/v/checker/assign.v @@ -702,6 +702,9 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) { && right is ast.StructInit && (right as ast.StructInit).is_anon { 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 // so that ident.obj is set diff --git a/vlib/v/checker/tests/struct_type_cast_err.out b/vlib/v/checker/tests/struct_type_cast_err.out index 131b1d15eb..9f069f89f4 100644 --- a/vlib/v/checker/tests/struct_type_cast_err.out +++ b/vlib/v/checker/tests/struct_type_cast_err.out @@ -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` 3 | fn main() { 4 | foo := Foo{}