Index: test/cctest/asmjs/test-asm-typer.cc |
diff --git a/test/cctest/asmjs/test-asm-typer.cc b/test/cctest/asmjs/test-asm-typer.cc |
index bf8615e00790d41fc6064a186f7e844b3b70817c..dcb778533dcf5767bb7e205420fd51fe3526c82b 100644 |
--- a/test/cctest/asmjs/test-asm-typer.cc |
+++ b/test/cctest/asmjs/test-asm-typer.cc |
@@ -1941,4 +1941,63 @@ TEST(B63099) { |
} |
} |
+// This issue was triggered because assignments to immutable symbols (e.g., the |
+// module's name, or any of the asm.js' module parameters) was not being |
+// handled. |
+TEST(B640194) { |
+ const char* kTests[] = { |
+ "function asm() {\n" |
+ " 'use asm';\n" |
+ " function f() {\n" |
+ " asm = 0;\n" |
+ " }\n" |
+ " return f;\n" |
+ "}", |
+ "function asm(stdlib) {\n" |
+ " 'use asm';\n" |
+ " function f() {\n" |
+ " stdlib = 0;\n" |
+ " }\n" |
+ " return f;\n" |
+ "}", |
+ "function asm(stdlib, foreign) {\n" |
+ " 'use asm';\n" |
+ " function f() {\n" |
+ " foreign = 0;\n" |
+ " }\n" |
+ " return f;\n" |
+ "}", |
+ "function asm(stdlib, foreign, heap) {\n" |
+ " 'use asm';\n" |
+ " function f() {\n" |
+ " heap = 0;\n" |
+ " }\n" |
+ " return f;\n" |
+ "}", |
+ "function asm(stdlib, foreign, heap) {\n" |
+ " 'use asm';\n" |
+ " var f = stdlib.Math.fround;\n" |
+ " function f() {\n" |
+ " f = 0;\n" |
+ " }\n" |
+ " return f;\n" |
+ "}", |
+ "function asm(stdlib, foreign, heap) {\n" |
+ " 'use asm';\n" |
+ " var E = stdlib.Math.E;\n" |
+ " function f() {\n" |
+ " E = 0;\n" |
+ " }\n" |
+ " return f;\n" |
+ "}", |
+ }; |
+ for (size_t ii = 0; ii < arraysize(kTests); ++ii) { |
+ if (!ValidationOf(Module(kTests[ii])) |
+ ->FailsWithMessage("Can't assign to immutable symbol")) { |
+ std::cerr << "Test:\n" << kTests[ii]; |
+ CHECK(false); |
+ } |
+ } |
+} |
+ |
} // namespace |