mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
compiler: prevent string to byte cast
This commit is contained in:
parent
437ba14521
commit
772c0c3f93
1 changed files with 3 additions and 0 deletions
|
@ -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)(')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue