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

checker: remove warning of casting same reference type (#17579)

This commit is contained in:
yuyi 2023-03-10 17:07:09 +08:00 committed by GitHub
parent 368604f9a5
commit 038fa6c8ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -2872,7 +2872,7 @@ fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
'a variadic' 'a variadic'
} }
c.error('cannot type cast ${msg}', node.pos) c.error('cannot type cast ${msg}', node.pos)
} else if !c.inside_unsafe && to_type.is_ptr() && from_type.is_ptr() } else if !c.inside_unsafe && to_type.is_ptr() && from_type.is_ptr() && to_type != from_type
&& to_type.deref() != ast.char_type && from_type.deref() != ast.char_type { && to_type.deref() != ast.char_type && from_type.deref() != ast.char_type {
ft := c.table.type_to_str(from_type) ft := c.table.type_to_str(from_type)
tt := c.table.type_to_str(to_type) tt := c.table.type_to_str(to_type)

View File

@ -0,0 +1 @@
&&nil

View File

@ -0,0 +1,5 @@
fn main() {
a := &&char(unsafe { nil })
b := &&char(a)
println(b)
}