Skip to content

Commit

Permalink
Add unit test to reproduce InlineFunctions bug
Browse files Browse the repository at this point in the history
Repro for #4115.

PiperOrigin-RevId: 563527535
  • Loading branch information
lauraharker authored and copybara-github committed Sep 7, 2023
1 parent d57b3c4 commit 6206b02
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/com/google/javascript/jscomp/InlineFunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3704,4 +3704,28 @@ public void testClassField() {
"class Foo { x = 0; }",
"f(new Foo());"));
}

@Test
public void testVariableUsedAsArgumentAndReassignedInFollowingArgument() {
// See https://github.com/google/closure-compiler/issues/4115.
test(
lines(
"function f(value, begin, end) {",
" return value.slice(begin, end);",
"}",
"window.g = function(a, b, c) {",
" return f(a, b + 1, b = c);",
"};"),
lines(
"window.g = function(a, b, c) {",
" var JSCompiler_inline_result$jscomp$0;",
" {",
// TODO(b/298828688): don't assign `b = c` here before `a.slice(b + 1,` below, since
// `b = c` should execute after the `b + 1`.
" var end$jscomp$inline_3 = b = c;",
" JSCompiler_inline_result$jscomp$0 = a.slice(b + 1, end$jscomp$inline_3);",
" }",
" return JSCompiler_inline_result$jscomp$0;",
"};"));
}
}

0 comments on commit 6206b02

Please sign in to comment.