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

Version 0.10 places Copy value literals behind a reference where 0.9 did not #404

Closed
agraven opened this issue Dec 16, 2020 · 7 comments · Fixed by #423
Closed

Version 0.10 places Copy value literals behind a reference where 0.9 did not #404

agraven opened this issue Dec 16, 2020 · 7 comments · Fixed by #423
Assignees

Comments

@agraven
Copy link

agraven commented Dec 16, 2020

I have a large collection of templates that compiles perfectly fine with version 0.9 of askama, but when I try to upgrade to 0.10, I get a bunch of type errors because a bunch of Copy types that were previously passed as values now get placed behind a reference

@djc
Copy link
Owner

djc commented Dec 16, 2020

Sorry for breaking your templates! Are these types being passed to macros, or to custom filters? Can you give an example?

We have some things in the works that will hopefully fix this.

@agraven
Copy link
Author

agraven commented Dec 16, 2020

Just off the top of my head, boolean literals, i.e. true and false are both passed to functions as &true and &false, and similarly Copy enum literals are placed behind a reference as well. There's some additional cases but I need to look closer to see exactly what happens in those

@vallentin
Copy link
Collaborator

As djc mentioned, it's in the works, that literals will be back to being moved by value. With the exception that fields from the template itself would still be referenced, and thus require clone() i.e. {{ self::and(self.b1.clone(), true) }}.

If you have any specific examples, different than variations of that case, then feel free to share it.

Also, hello fellow Dane! :)

@vallentin
Copy link
Collaborator

@agraven the issue should now be resolved. Feel free to try building with the repository as a dependency, to verify if all your issues have been resolved. If not, please re-open or create a new issue.

[dependencies]
askama = { git = "https://github.com/djc/askama", rev = "f9db444" }

Note that e.g. {{ self::foo(true) }} should work now. However, if a field is used, then that requires an explicit clone, e.g. {{ self::foo(self.b.clone()) }}.

@danielalvsaaker
Copy link

@vallentin When can we expect this change to be published to the crate?

@vallentin
Copy link
Collaborator

@danielalvsaaker I think we want to resolve a few more things, until we publish a new version.

That said, @djc is in charge of publishing :)

@djc
Copy link
Owner

djc commented Feb 18, 2021

I opened #451 to discuss the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants