From 476232cb2335eac8867da7dd8a5b99c129523d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Gro=C3=9F?= Date: Wed, 31 Jul 2024 11:01:57 +0200 Subject: [PATCH] Fix basic_scoping.js compiler test See the added comments for more details. --- .../CompilerTests/basic_scoping.js | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Tests/FuzzilliTests/CompilerTests/basic_scoping.js b/Tests/FuzzilliTests/CompilerTests/basic_scoping.js index e774dc724..1b5b6d34b 100644 --- a/Tests/FuzzilliTests/CompilerTests/basic_scoping.js +++ b/Tests/FuzzilliTests/CompilerTests/basic_scoping.js @@ -16,12 +16,21 @@ function foo(x) { } output(x); output(y); - let obj = { x: 45, y: 9001 }; - with (obj) { - output(x); - output(y); - } +} +foo(44); + +// Note: this test will currently fail if 'a' and 'b' are replaced by +// 'x' and 'y' in the object. That's because the compiler will still used +// regular/numbered variables for x and y, and so will effectively rename +// them to something like `v1` and `v2`, while keeping the property names +// of the object. This isn't easy to fix, unfortunately. One option might +// be to change the compiler to only use named variables in testcases that +// use `with` statements, but that would be quite an invasive change and +// result in a FuzzIL program that is less suited for mutations. +let obj = { a: 45, b: 9001 }; +with (obj) { output(x); output(y); + output(a); + output(b); } -foo(44);