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

compiler: prevent string to byte cast

This commit is contained in:
Henrixounez 2019-08-13 18:28:52 +02:00 committed by Alexander Medvednikov
parent 437ba14521
commit 772c0c3f93

View File

@ -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)(')
}