From 7fc7c05e9df21d45a6a1b273eb3f981d183d18a1 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 5 Nov 2019 20:41:02 +0300 Subject: [PATCH] parser: do not all string casts --- vlib/compiler/gen_c.v | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vlib/compiler/gen_c.v b/vlib/compiler/gen_c.v index b68d9d98ec..6cd5bcc0ca 100644 --- a/vlib/compiler/gen_c.v +++ b/vlib/compiler/gen_c.v @@ -523,6 +523,10 @@ fn (p mut Parser) cast(typ string) { } p.error('cannot cast `$expr_typ` to `bool`') } + // Strings can't be cast + if expr_typ == 'string' { + p.error('cannot cast `$expr_typ` to `$typ`') + } p.cgen.set_placeholder(pos, '($typ)(') } p.check(.rpar)