From 6e4ae5a5e6afdb1b24e560243480bbbcce1470a2 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 16 May 2020 22:48:41 +0200 Subject: [PATCH] checker: do not allow casting strings --- vlib/v/checker/checker.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 5c0bc680d4..7df8b30776 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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) }