Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text/template: inconsistency when accessing a field of an interface field #12924

Closed
nodirt opened this issue Oct 13, 2015 · 5 comments
Closed

Comments

@nodirt
Copy link
Contributor

nodirt commented Oct 13, 2015

In a pipeline {{.Foo.Bar}} where Foo field is declared as of type interface I and points to a struct S that implements I and has Bar field:

  • Bar can be resolved if I is interface{}
  • Bar cannot be resolved if I is a non-empty interface

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

I think this is inconsistent, Bar should be resolvable with non-empty I.
This wasn't catched by tests because there is a test for interface{}, but not for a non-empty interface.

I'd like to work on this.

@adg adg added this to the Unplanned milestone Oct 14, 2015
@adg
Copy link
Contributor

adg commented Oct 14, 2015

This does seem inconsistent. It also seems like a bad thing to rely on. Happy to review a fix.

@gopherbot
Copy link

CL https://golang.org/cl/15809 mentions this issue.

@nodirt
Copy link
Contributor Author

nodirt commented Oct 14, 2015

While reading the code, discovered one more case
http://play.golang.org/p/eM7lrc1lIM

I think we have to support this because templates are inherently dynamically-typed.

@nodirt
Copy link
Contributor Author

nodirt commented Oct 14, 2015

Same thing with len http://play.golang.org/p/qXOU4I5Vyj

@nodirt
Copy link
Contributor Author

nodirt commented Oct 14, 2015

And with range

@adg adg closed this as completed in 167a712 Oct 15, 2015
@golang golang locked and limited conversation to collaborators Oct 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants