diff --git a/vlib/builtin/cfns_wrapper.c.v b/vlib/builtin/cfns_wrapper.c.v index e2820c4c96..e0adc02023 100644 --- a/vlib/builtin/cfns_wrapper.c.v +++ b/vlib/builtin/cfns_wrapper.c.v @@ -3,7 +3,7 @@ module builtin // vstrlen returns the V length of the C string `s` (0 terminator is not counted). // The C string is expected to be a &byte pointer. [inline; unsafe] -pub fn vstrlen(s &byte) int { +pub fn vstrlen(s &u8) int { return unsafe { C.strlen(&char(s)) } } diff --git a/vlib/builtin/string_interpolation.v b/vlib/builtin/string_interpolation.v index 20300084f0..007541c122 100644 --- a/vlib/builtin/string_interpolation.v +++ b/vlib/builtin/string_interpolation.v @@ -64,7 +64,7 @@ pub fn (x StrIntpType) str() string { pub union StrIntpMem { pub mut: d_c u32 - d_u8 byte + d_u8 u8 d_i8 i8 d_u16 u16 d_i16 i16 @@ -114,7 +114,7 @@ fn abs64(x i64) u64 { //--------------------------------------- // convert from data format to compact u64 -pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch byte, in_base int, in_upper_case bool) u64 { +pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u64 { width := if in_width != 0 { abs64(in_width) } else { u64(0) } allign := if in_width > 0 { u64(1 << 5) } else { u64(0) } // two bit 0 .left 1 .rigth, for now we use only one upper_case := if in_upper_case { u64(1 << 7) } else { u64(0) } @@ -131,7 +131,7 @@ pub fn get_str_intp_u64_format(fmt_type StrIntpType, in_width int, in_precision } // convert from data format to compact u32 -pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch byte, in_base int, in_upper_case bool) u32 { +pub fn get_str_intp_u32_format(fmt_type StrIntpType, in_width int, in_precision int, in_tail_zeros bool, in_sign bool, in_pad_ch u8, in_base int, in_upper_case bool) u32 { width := if in_width != 0 { abs64(in_width) } else { u32(0) } allign := if in_width > 0 { u32(1 << 5) } else { u32(0) } // two bit 0 .left 1 .rigth, for now we use only one upper_case := if in_upper_case { u32(1 << 7) } else { u32(0) } diff --git a/vlib/crypto/internal/subtle/comparison.v b/vlib/crypto/internal/subtle/comparison.v index ba3bd381ad..56a43b830d 100644 --- a/vlib/crypto/internal/subtle/comparison.v +++ b/vlib/crypto/internal/subtle/comparison.v @@ -1,7 +1,7 @@ module subtle // constant_time_byte_eq returns 1 when x == y. -pub fn constant_time_byte_eq(x byte, y byte) int { +pub fn constant_time_byte_eq(x u8, y u8) int { return int((u32(x ^ y) - 1) >> 31) } diff --git a/vlib/db/mysql/stmt.c.v b/vlib/db/mysql/stmt.c.v index e0da0edd0d..13a495c3f5 100644 --- a/vlib/db/mysql/stmt.c.v +++ b/vlib/db/mysql/stmt.c.v @@ -188,7 +188,7 @@ pub fn (mut stmt Stmt) bind_bool(b &bool) { } // bind_byte binds a single byte value to the statement `stmt` -pub fn (mut stmt Stmt) bind_byte(b &byte) { +pub fn (mut stmt Stmt) bind_byte(b &u8) { stmt.bind(mysql.mysql_type_tiny, b, 0) } diff --git a/vlib/json/json_primitives.v b/vlib/json/json_primitives.v index f10f9426d6..a2b18af4a9 100644 --- a/vlib/json/json_primitives.v +++ b/vlib/json/json_primitives.v @@ -194,8 +194,8 @@ fn encode_i64(val i64) &C.cJSON { // TODO: remove when `byte` is removed [markused] -fn encode_byte(root byte) &C.cJSON { - return encode_u8(u8(root)) +fn encode_byte(root u8) &C.cJSON { + return encode_u8(root) } [markused] diff --git a/vlib/strings/builder.c.v b/vlib/strings/builder.c.v index e0b8b3c23d..cf8bfef4e8 100644 --- a/vlib/strings/builder.c.v +++ b/vlib/strings/builder.c.v @@ -70,7 +70,7 @@ pub fn (mut b Builder) write_u8(data u8) { } // write_byte appends a single `data` byte to the accumulated buffer -pub fn (mut b Builder) write_byte(data byte) { +pub fn (mut b Builder) write_byte(data u8) { b << data } diff --git a/vlib/strings/builder.js.v b/vlib/strings/builder.js.v index ede1e73d83..aca8d7f1d4 100644 --- a/vlib/strings/builder.js.v +++ b/vlib/strings/builder.js.v @@ -18,7 +18,7 @@ pub fn new_builder(initial_size int) Builder { return []u8{cap: initial_size} } -pub fn (mut b Builder) write_byte(data byte) { +pub fn (mut b Builder) write_byte(data u8) { b << data } diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 93e4b70638..51d4ee5c36 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -271,6 +271,9 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) { if c.check_import_sym_conflict(param.name) { c.error('duplicate of an import symbol `${param.name}`', param.pos) } + if arg_typ_sym.kind == .alias && arg_typ_sym.name == 'byte' { + c.warn('byte is deprecated, use u8 instead', param.type_pos) + } } if !node.is_method { // Check if function name is already registered as imported module symbol diff --git a/vlib/v/checker/tests/top_level_fn_builtin_decl_err.out b/vlib/v/checker/tests/top_level_fn_builtin_decl_err.out index 4cdeaa5712..44a45a0324 100644 --- a/vlib/v/checker/tests/top_level_fn_builtin_decl_err.out +++ b/vlib/v/checker/tests/top_level_fn_builtin_decl_err.out @@ -1,3 +1,10 @@ +vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:3:12: warning: byte is deprecated, use u8 instead + 1 | + 2 | [inline] + 3 | fn char(ch byte) fn (string) !(byte, string) { + | ~~~~ + 4 | return fn [ch] (input string) !(byte, string) { + 5 | return if input[0] == ch { vlib/v/checker/tests/top_level_fn_builtin_decl_err.vv:3:1: error: top level declaration cannot shadow builtin type 1 | 2 | [inline]