diff --git a/vlib/v/checker/check_types.v b/vlib/v/checker/check_types.v index dda2e53936..8aad2cac64 100644 --- a/vlib/v/checker/check_types.v +++ b/vlib/v/checker/check_types.v @@ -54,31 +54,36 @@ pub fn (mut c Checker) check_expected_call_arg(got ast.Type, expected_ ast.Type, } idx_got := got.idx() idx_expected := expected.idx() - if idx_got in [ ast.byteptr_type_idx, ast.charptr_type_idx] || idx_expected in [ast.byteptr_type_idx, ast.charptr_type_idx] { + if idx_got in [ast.byteptr_type_idx, ast.charptr_type_idx] + || idx_expected in [ast.byteptr_type_idx, ast.charptr_type_idx] { igot := int(got) iexpected := int(expected) // TODO: remove; transitional compatibility for byteptr === &byte if (igot == ast.byteptr_type_idx && iexpected == 65545) - || (iexpected == ast.byteptr_type_idx && igot == 65545) { + || (iexpected == ast.byteptr_type_idx && igot == 65545) { return } // TODO: remove; transitional compatibility for charptr === &char if (igot == ast.charptr_type_idx && iexpected == 65551) - || (iexpected == ast.charptr_type_idx && igot == 65551) { + || (iexpected == ast.charptr_type_idx && igot == 65551) { return } muls_got := got.nr_muls() muls_expected := expected.nr_muls() - if idx_got == ast.byteptr_type_idx && idx_expected == ast.byte_type_idx && muls_got + 1 == muls_expected { + if idx_got == ast.byteptr_type_idx && idx_expected == ast.byte_type_idx + && muls_got + 1 == muls_expected { return } - if idx_expected == ast.byteptr_type_idx && idx_got == ast.byte_type_idx && muls_expected + 1 == muls_got { + if idx_expected == ast.byteptr_type_idx && idx_got == ast.byte_type_idx + && muls_expected + 1 == muls_got { return } - if idx_got == ast.charptr_type_idx && idx_expected == ast.char_type_idx && muls_got + 1 == muls_expected { + if idx_got == ast.charptr_type_idx && idx_expected == ast.char_type_idx + && muls_got + 1 == muls_expected { return } - if idx_expected == ast.charptr_type_idx && idx_got == ast.char_type_idx && muls_expected + 1 == muls_got { + if idx_expected == ast.charptr_type_idx && idx_got == ast.char_type_idx + && muls_expected + 1 == muls_got { return } } diff --git a/vlib/v/gen/x64/gen.v b/vlib/v/gen/x64/gen.v index 6d19e6ff60..60563aceb2 100644 --- a/vlib/v/gen/x64/gen.v +++ b/vlib/v/gen/x64/gen.v @@ -684,7 +684,7 @@ fn (mut g Gen) stmt(node ast.Stmt) { } } -fn C.strtol(str charptr, endptr &&char, base int) int +fn C.strtol(str &char, endptr &&char, base int) int fn (mut g Gen) expr(node ast.Expr) { // println('cgen expr()') diff --git a/vlib/v/tests/offsetof_test.v b/vlib/v/tests/offsetof_test.v index 6ae8acb24c..f03aa2eefa 100644 --- a/vlib/v/tests/offsetof_test.v +++ b/vlib/v/tests/offsetof_test.v @@ -15,17 +15,17 @@ fn test_offsetof() { age: 2147483647 } unsafe { - assert *(&string(byteptr(&cat) + __offsetof(Cat, name))) == 'Cthulhu' - assert *(&string(byteptr(&cat) + __offsetof(Cat, breed))) == 'Great Old One' - assert *(&int(byteptr(&cat) + __offsetof(Cat, age))) == 2147483647 + assert *(&string(&byte(&cat) + __offsetof(Cat, name))) == 'Cthulhu' + assert *(&string(&byte(&cat) + __offsetof(Cat, breed))) == 'Great Old One' + assert *(&int(&byte(&cat) + __offsetof(Cat, age))) == 2147483647 } } fn test_offsetof_struct_from_another_module() { num := complex.Complex{1.0, 1.0} unsafe { - assert *(&f64(byteptr(&num) + __offsetof(complex.Complex, re))) == 1.0 - assert *(&f64(byteptr(&num) + __offsetof(complex.Complex, im))) == 1.0 + assert *(&f64(&byte(&num) + __offsetof(complex.Complex, re))) == 1.0 + assert *(&f64(&byte(&num) + __offsetof(complex.Complex, im))) == 1.0 } } @@ -36,8 +36,8 @@ fn test_offsetof_alias() { age: 2147483647 } unsafe { - assert *(&string(byteptr(&fel) + __offsetof(Feline, name))) == 'Cthulhu' - assert *(&string(byteptr(&fel) + __offsetof(Feline, breed))) == 'Great Old One' - assert *(&int(byteptr(&fel) + __offsetof(Feline, age))) == 2147483647 + assert *(&string(&byte(&fel) + __offsetof(Feline, name))) == 'Cthulhu' + assert *(&string(&byte(&fel) + __offsetof(Feline, breed))) == 'Great Old One' + assert *(&int(&byte(&fel) + __offsetof(Feline, age))) == 2147483647 } }