Skip to content

Commit

Permalink
const: n < iota support
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioCarrion committed Sep 24, 2019
1 parent d90e955 commit a8fa904
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ func (c *ConstsValidator) Validate(v *ast.GenDecl, fset *token.FileSet) error {
}

for _, vss := range s.Values {
_, ok := vss.(*ast.Ident)
bexpr, ok := vss.(*ast.BinaryExpr)
if ok {
vss = bexpr.Y
}

_, ok = vss.(*ast.Ident)
if ok {
return nil // iota
}
Expand Down
1 change: 1 addition & 0 deletions testdata/consts_iota.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ const (
Bla = "iota"
Consts_iota = iota
Consts_iota2 = iota + 1
Consts_iota0 = 1 << iota
Consts_iota1
)

0 comments on commit a8fa904

Please sign in to comment.