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

stow the created template on the parser #7

Closed
wants to merge 1 commit into from

Conversation

jbohanon
Copy link

@jbohanon jbohanon commented Mar 14, 2024

The variable result was a dangling reference when returning from Parser::parse function, so we stash the template on the Parser and use a reference to that object instead.

@jbohanon
Copy link
Author

This change has been proposed to upstream in pantor#288, but that repo does not see much maintenance.

@@ -2060,7 +2061,7 @@ class Parser {
: config(parser_config), lexer(lexer_config), template_storage(template_storage), function_storage(function_storage) {}

Template parse(std::string_view input, std::string_view path) {
auto result = Template(static_cast<std::string>(input));
auto& result = template_stash.emplace_back(Template(static_cast<std::string>(input)));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it seems like it might be more correct to use make_shared to handle this

@jbohanon
Copy link
Author

#8

@jbohanon jbohanon closed this Mar 15, 2024
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 this pull request may close these issues.

2 participants