aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/compiler/check.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-01-23 10:44:01 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-01-23 10:44:01 +0100
commitde3e24c4b6cd0136618ce74eb025a15d4834c082 (patch)
tree9a9653ad878ef929b6630fa82a0c7626d2de8d41 /pkg/compiler/check.go
parent228e3d951cef1d13723fd60ab957a9c81415c84a (diff)
pkg/compiler: allow strings as template arguments
Needed for netfilter descriptions.
Diffstat (limited to 'pkg/compiler/check.go')
-rw-r--r--pkg/compiler/check.go7
1 files changed, 1 insertions, 6 deletions
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go
index 4187f8a96..5d741effc 100644
--- a/pkg/compiler/check.go
+++ b/pkg/compiler/check.go
@@ -670,12 +670,6 @@ func (comp *compiler) replaceTypedef(ctx *checkCtx, t *ast.Type, desc *typeDesc,
ctx.instantiationStack = append(ctx.instantiationStack, fullTypeName)
nargs := len(typedef.Args)
args := t.Args
- for _, arg := range args {
- if arg.String != "" {
- comp.error(arg.Pos, "template arguments can't be strings (%q)", arg.String)
- return
- }
- }
if nargs != len(t.Args) {
if nargs == 0 {
comp.error(t.Pos, "type %v is not a template", typedefName)
@@ -734,6 +728,7 @@ func (comp *compiler) instantiate(templ ast.Node, params []*ast.Ident, args []*a
// TODO(dvyukov): somewhat hacky, but required for int8[0:CONST_ARG]
// Need more checks here. E.g. that CONST_ARG does not have subargs.
// And if CONST_ARG is a value, then use concreteArg.Value.
+ // Also need to error if CONST_ARG is a string.
if concreteArg := argMap[templArg.Ident2]; concreteArg != nil {
templArg.Ident2 = concreteArg.Ident
templArg.Pos2 = concreteArg.Pos