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: :=, =, !, %, etc all assign to variables #3271

Closed
rsc opened this issue Mar 10, 2012 · 2 comments
Closed

text/template: :=, =, !, %, etc all assign to variables #3271

rsc opened this issue Mar 10, 2012 · 2 comments
Milestone

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Mar 10, 2012

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

        {{$x:=0}}{{$x}}
        {{$x=1}}{{$x}}
        {{$x!2}}{{$x}}
        {{$x%3}}{{$x}}

prints

        0
        1
        2
        3
@rsc
Copy link
Contributor Author

@rsc rsc commented Mar 10, 2012

Comment 1:

Changing to Go1-Must to avoid breaking Go 1 programs later.
The fix should disallow = for assignment, even though it is used (probably accidentally)
in one test.  A simple, useful future addition would be to have = for reassigning
existing variables, so it is important that = not be equivalent to := now.
This is the test that will need changing:
    {"variable declared by template", `{{template "nested" $x=.SI}},{{index $x 1}}`, "[3 4 5],4", tVal, true},

Labels changed: added go1-must.

@robpike
Copy link
Contributor

@robpike robpike commented Mar 13, 2012

Comment 2:

This issue was closed by revision 8170d81.

Status changed to Fixed.

@rsc rsc added fixed labels Mar 13, 2012
@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed priority-go1 labels Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.