summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-05-04 16:32:32 +0200
committerJo-Philipp Wich <jo@mein.io>2021-05-04 16:32:32 +0200
commit16604331c185d7597b53709cc09a072a2652415e (patch)
tree175777b9c4ac0ee49fd1b9de01527e3063d26d91
parent799c9f4dbe123536e1dde1639a122f48dcf75a05 (diff)
compiler: fix stack mismatch on compiling `use strict` statements
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--compiler.c1
-rw-r--r--tests/custom/03_bugs/20_use_strict_stack_mismatch17
2 files changed, 17 insertions, 1 deletions
diff --git a/compiler.c b/compiler.c
index bbd6dbc..00079fd 100644
--- a/compiler.c
+++ b/compiler.c
@@ -1374,7 +1374,6 @@ uc_compiler_compile_constant(uc_compiler *compiler, bool assignable)
if (uc_compiler_is_use_strict_pragma(compiler)) {
fn = (uc_function_t *)compiler->function;
fn->strict = true;
- break;
}
/* fall through */
diff --git a/tests/custom/03_bugs/20_use_strict_stack_mismatch b/tests/custom/03_bugs/20_use_strict_stack_mismatch
new file mode 100644
index 0000000..7294d23
--- /dev/null
+++ b/tests/custom/03_bugs/20_use_strict_stack_mismatch
@@ -0,0 +1,17 @@
+When compiling the `use strict` statement, the compiler omitted the
+corresponding load instruction, leading to a mismatch of the expected
+stack layout between compiler and VM.
+
+-- Expect stdout --
+1
+-- End --
+
+-- Testcase --
+{%
+ "use strict";
+
+ let x = 1;
+
+ print(x, "\n");
+%}
+-- End --