Skip to content

text/template: chained nodes in pipe command arguments cause errors at runtime #8473

@gopherbot

Description

@gopherbot

by walken@google.com:

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

http://play.golang.org/p/AUK0RsmDNu

1. import text/template
2. parse template with a function whose argument is a chained node: {{.F (.G 42).X}}
3. execute that template

What happened?
template parsed without errors, but its Execute() function returned an error.

What should have happened instead?
the template should have printed the function's result - 42 in my example code.

Please provide any additional information below.
In text/template/exec.go, evalArg() needs to handle the parse.ChainNode case:

    case *parse.IdentifierNode:
        return s.evalFunction(dot, arg, arg, nil, zero)
+   case *parse.ChainNode:
+       return s.validateType(s.evalChainNode(dot, arg, nil, zero), typ)
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions