Skip to content

Commit

Permalink
Variable protected names (#18921)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zoesteinkamp authored Jul 10, 2020
1 parent b2923d0 commit e8aeba4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit e8aeba4

Please sign in to comment.