Skip to content

Commit 6206b02

Browse files
lauraharkercopybara-github
authored andcommitted
Add unit test to reproduce InlineFunctions bug
Repro for #4115. PiperOrigin-RevId: 563527535
1 parent d57b3c4 commit 6206b02

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/com/google/javascript/jscomp/InlineFunctionsTest.java

+24
Original file line numberDiff line numberDiff line change
@@ -3704,4 +3704,28 @@ public void testClassField() {
37043704
"class Foo { x = 0; }",
37053705
"f(new Foo());"));
37063706
}
3707+
3708+
@Test
3709+
public void testVariableUsedAsArgumentAndReassignedInFollowingArgument() {
3710+
// See https://github.com/google/closure-compiler/issues/4115.
3711+
test(
3712+
lines(
3713+
"function f(value, begin, end) {",
3714+
" return value.slice(begin, end);",
3715+
"}",
3716+
"window.g = function(a, b, c) {",
3717+
" return f(a, b + 1, b = c);",
3718+
"};"),
3719+
lines(
3720+
"window.g = function(a, b, c) {",
3721+
" var JSCompiler_inline_result$jscomp$0;",
3722+
" {",
3723+
// TODO(b/298828688): don't assign `b = c` here before `a.slice(b + 1,` below, since
3724+
// `b = c` should execute after the `b + 1`.
3725+
" var end$jscomp$inline_3 = b = c;",
3726+
" JSCompiler_inline_result$jscomp$0 = a.slice(b + 1, end$jscomp$inline_3);",
3727+
" }",
3728+
" return JSCompiler_inline_result$jscomp$0;",
3729+
"};"));
3730+
}
37073731
}

0 commit comments

Comments
 (0)