parser: do not all string casts

pull/2660/head
Alexander Medvednikov 2019-11-05 20:41:02 +03:00
parent b91a537c35
commit 7fc7c05e9d
1 changed files with 4 additions and 0 deletions

View File

@ -523,6 +523,10 @@ fn (p mut Parser) cast(typ string) {
} }
p.error('cannot cast `$expr_typ` to `bool`') 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.cgen.set_placeholder(pos, '($typ)(')
} }
p.check(.rpar) p.check(.rpar)