From 772c0c3f931e23df7a0d51bbbc6923cbde3129a7 Mon Sep 17 00:00:00 2001 From: Henrixounez Date: Tue, 13 Aug 2019 18:28:52 +0200 Subject: [PATCH] compiler: prevent string to byte cast --- compiler/parser.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/parser.v b/compiler/parser.v index 9f2a618428..624f05e7f4 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -2920,6 +2920,9 @@ fn (p mut Parser) cast(typ string) string { p.error('cannot cast `$expr_typ` to `$typ`') } } + else if typ == 'byte' && expr_typ == 'string' { + p.error('cannot cast `$expr_typ` to `$typ`, use backquotes `` to create a `$typ` or access the value of an index of `$expr_typ` using []') + } else { p.cgen.set_placeholder(pos, '($typ)(') }