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

checker: do not allow casting strings

This commit is contained in:
Alexander Medvednikov 2020-05-16 22:48:41 +02:00
parent e245e22875
commit 6e4ae5a5e6

View File

@ -1686,6 +1686,9 @@ pub fn (mut c Checker) expr(node ast.Expr) table.Type {
type_name := c.table.type_to_str(it.expr_type)
c.error('cannot cast type `$type_name` to string, use `x.str()` instead', it.pos)
}
if it.expr_type == table.string_type {
c.error('cannot cast a string', it.pos)
}
if it.has_arg {
c.expr(it.arg)
}