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 variablepull/18920/head
parent
b2923d0320
commit
e8aeba4b45
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue