• Didier Spezia's avatar
    text/template: check for literals in chain of terms · 76ace947
    Didier Spezia authored
    The current parser ignores obvious errors such as:
    {{0.1.E}}
    {{true.any}}
    {{"hello".wrong}}
    {{nil.E}}
    
    The common problem is that a chain is built from
    a literal value. It then panics at execution time.
    
    Furthermore, a double dot triggers the same behavior:
    {{..E}}
    
    Addresses a TODO left in Tree.operand to catch these
    errors at parsing time.
    
    Note that identifiers can include a '.', and pipelines
    could return an object which a field can be derived
    from (like a variable), so they are excluded from the check.
    
    Fixes #10615
    
    Change-Id: I903706d1c17861b5a8354632c291e73c9c0bc4e1
    Reviewed-on: https://go-review.googlesource.com/9621Reviewed-by: 's avatarRob Pike <r@golang.org>
    76ace947
parse_test.go 14.5 KB