Add some ast.Expr.IsEtc methods

This commit is contained in:
Nigel Tao committed 2021-03-28 23:07:21 +11:00
1 parent b645180357
commit 41e407a774
7 files changed
+58 -48

No files matched your search

+6 -5
View File
@@ -391,12 +391,13 @@ func (c *Checker) checkConst(node *a.Node) error {
func (c *Checker) checkConstElement(n *a.Expr, nb bounds, nLists int) error {
if nLists > 0 {
nLists--
if n.Operator() != t.IDComma {
if args, ok := n.IsList(); !ok {
return fmt.Errorf("invalid const value %q", n.Str(c.tm))
}
for _, o := range n.Args() {
if err := c.checkConstElement(o.AsExpr(), nb, nLists); err != nil {
return err
} else {
for _, o := range args {
if err := c.checkConstElement(o.AsExpr(), nb, nLists); err != nil {
return err
}
}
}
return nil