Variable protected names (#18921)

* Fix: Add Protected names to variable

* Fix: Add Protected names to variable

* Fix: Add Protected names to variable

fixing go lint

* Fix: Add Protected names to variable
pull/18920/head
Zoe Steinkamp 2020-07-10 15:46:48 -06:00 committed by GitHub
parent b2923d0320
commit e8aeba4b45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -127,6 +127,15 @@ func (m *Variable) Valid() error {
return fmt.Errorf("invalid arguments type")
}
inValidNames := [11]string{"and", "import", "not", "return", "option", "test", "empty", "in", "or", "package", "builtin"}
for x := range inValidNames {
if m.Name == inValidNames[x] {
return fmt.Errorf("%q is a protected variable name", inValidNames[x])
}
}
return nil
}