aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2021-11-15 10:01:43 -0800
committerKeith Randall <khr@golang.org>2021-11-15 21:21:51 +0000
commit560dc9712d4bc900b5ab32b518ba4de2a9bc588c (patch)
tree214681686e2ef4f140ce47ded79889389b81afae /src/cmd/compile/internal/noder
parent92655582d0d3b739a1fc88c73cc49a24eb57f845 (diff)
downloadgo-560dc9712d4bc900b5ab32b518ba4de2a9bc588c.tar.xz
cmd/compile: error when using internal type declarations in generic functions
We hope to support this feature one day, but it doesn't work currently. Issue a nice error message instead of having the compiler crash. Update #47631 Change-Id: I0359411410acbaf9a5b9dbb988cd933de1bb8438 Reviewed-on: https://go-review.googlesource.com/c/go/+/364054 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/stmt.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/stmt.go b/src/cmd/compile/internal/noder/stmt.go
index aedb09e21e..e329a59156 100644
--- a/src/cmd/compile/internal/noder/stmt.go
+++ b/src/cmd/compile/internal/noder/stmt.go
@@ -46,6 +46,10 @@ func (g *irgen) stmt(stmt syntax.Stmt) ir.Node {
n.SetTypecheck(1)
return n
case *syntax.DeclStmt:
+ if _, ok := stmt.DeclList[0].(*syntax.TypeDecl); ok && g.topFuncIsGeneric {
+ // TODO: remove this restriction. See issue 47631.
+ base.ErrorfAt(g.pos(stmt), "type declarations inside generic functions are not currently supported")
+ }
n := ir.NewBlockStmt(g.pos(stmt), nil)
g.decls(&n.List, stmt.DeclList)
return n