Skip to content

Commit 4719a06

Browse files
committed
go/ir: permit rangefunc yield functions to be synthetic wihle having syntax
1 parent 95e1ba4 commit 4719a06

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

go/ir/sanity.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ package ir
1010
import (
1111
"bytes"
1212
"fmt"
13+
"go/ast"
1314
"go/types"
1415
"io"
1516
"os"
@@ -462,7 +463,10 @@ func (s *sanity) checkFunction(fn *Function) bool {
462463
}
463464
}
464465
if syn, src := fn.Synthetic == 0, fn.source != nil; src != syn {
465-
s.errorf("got fromSource=%t, hasSyntax=%t; want same values", src, syn)
466+
if _, ok := fn.source.(*ast.RangeStmt); !ok || fn.Synthetic != SyntheticRangeOverFuncYield {
467+
// Only range-over-func yield functions are synthetic and have syntax
468+
s.errorf("got fromSource=%t, hasSyntax=%t; want same values", src, syn)
469+
}
466470
}
467471
for i, l := range fn.Locals {
468472
if l.Parent() != fn {

0 commit comments

Comments
 (0)