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

Fix corner cases with returning values #12

Closed
wants to merge 2 commits into from

Conversation

TimothyGu
Copy link
Member

[closes pugjs/pug#2409]

replace(node, 'return {value: ' + source(node.argument) + '};');
hasReturn = true;
if (node.argument) {
replace(node, 'return {value: (' + source(node.argument) + ')};');
Copy link
Member

Choose a reason for hiding this comment

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

Even if there's no argument, we still need to re-write to return {value: undefined}. Otherwise the code generated by with won't be able to tell that a return has happened.

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.

"TypeError: Cannot read property 'start' of null" because of inline JS return statement
2 participants