Skip to content

Commit

Permalink
go/ir: permit rangefunc yield functions to be synthetic wihle having …
Browse files Browse the repository at this point in the history
…syntax
  • Loading branch information
dominikh committed May 25, 2024
1 parent 95e1ba4 commit 4719a06
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion go/ir/sanity.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package ir
import (
"bytes"
"fmt"
"go/ast"
"go/types"
"io"
"os"
Expand Down Expand Up @@ -462,7 +463,10 @@ func (s *sanity) checkFunction(fn *Function) bool {
}
}
if syn, src := fn.Synthetic == 0, fn.source != nil; src != syn {
s.errorf("got fromSource=%t, hasSyntax=%t; want same values", src, syn)
if _, ok := fn.source.(*ast.RangeStmt); !ok || fn.Synthetic != SyntheticRangeOverFuncYield {
// Only range-over-func yield functions are synthetic and have syntax
s.errorf("got fromSource=%t, hasSyntax=%t; want same values", src, syn)
}
}
for i, l := range fn.Locals {
if l.Parent() != fn {
Expand Down

0 comments on commit 4719a06

Please sign in to comment.