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)