parser: do not allow variable names with capital letters

pull/4413/head
Alexander Medvednikov 2020-04-14 20:39:55 +02:00
parent 91de4e1ece
commit 14e1b963f2
1 changed files with 3 additions and 0 deletions

View File

@ -1784,6 +1784,9 @@ fn (p mut Parser) assign_stmt() ast.Stmt {
exprs := p.parse_assign_rhs()
is_decl := op == .decl_assign
for i, ident in idents {
if op == .decl_assign && scanner.contains_capital(ident.name) {
p.error('variable names cannot contain uppercase letters, use snake_case instead')
}
known_var := p.scope.known_var(ident.name)
if !is_decl && !known_var {
p.error('unknown variable `$ident.name`')