Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Jan 2, 2024
1 parent 6bcb47e commit 53f57fc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -3180,7 +3180,8 @@ fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
snexpr := node.expr.str()
tt := c.table.type_to_str(to_type)
c.error('cannot cast string to `${tt}`, use `${snexpr}[index]` instead.', node.pos)
} else if final_from_sym.kind == .string && to_type.is_voidptr() {
} else if final_from_sym.kind == .string && to_type.is_voidptr()
&& !node.expr_type.has_flag(.generic) {
c.error('cannot cast string to `voidptr`, use voidptr(s.str) instead', node.pos)
} else if final_from_sym.kind == .string && to_type.is_pointer() && !c.inside_unsafe {
tt := c.table.type_to_str(to_type)
Expand Down

0 comments on commit 53f57fc

Please sign in to comment.