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

LogicalExpression tree shaking optimisation breaks with comment #3761

Closed
tanhauhau opened this issue Sep 4, 2020 · 3 comments · Fixed by #3762
Closed

LogicalExpression tree shaking optimisation breaks with comment #3761

tanhauhau opened this issue Sep 4, 2020 · 3 comments · Fixed by #3762

Comments

@tanhauhau
Copy link

tanhauhau commented Sep 4, 2020

  • Rollup Version: 2.26.9
  • Operating System (or Browser): chrome
  • Node Version (if applicable):
  • Link to reproduction (IMPORTANT, read below):
function foo() {
	return true && // comment
		1;
}

function bar() {
	return false || // comment
		1;
}


function baz() {
	return null ?? // comment
		1;
}
	
console.log(foo());
console.log(bar());
console.log(baz());

Rollup REPL

Expected Behavior

should print out '1' for all cases

Actual Behavior

prints out undefined

Rollup outputs:

function foo() {
	return  // comment		1;
}

function bar() {
	return  // comment		1;
}


function baz() {
	return  // comment		1;
}
	
console.log(foo());
console.log(bar());
console.log(baz());
@tanhauhau
Copy link
Author

tanhauhau commented Sep 4, 2020

related: #3734, #3035

@lukastaegert
Copy link
Member

Thanks for spotting. So it is actually the original ASI PR #3035 that broke this, I will have a look how to fix this. So I believe the solution must be to either remove line comments completely or turn them into block comments in such situations as they always imply a line-break. I'm leaning towards removing them for now as the simple solution.

@lukastaegert
Copy link
Member

Fix at #3762

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

Successfully merging a pull request may close this issue.

2 participants