Bug 1198673 - Fix bug in parseModule() error handling r=jandem
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 26 Aug 2015 13:07:53 +0100
changeset 288046 0a6629904b68ff9aca323231cde87643ecbc82b3
parent 288045 67ad669ce0ad2a7325f836c69d6ce357db58b7d1
child 288047 f7893bbf4cb3809fe88a78587e9e23a7a400ecd4
push id4792
push useryura.zenevich@gmail.com
push dateWed, 26 Aug 2015 20:00:52 +0000
reviewersjandem
bugs1198673
milestone43.0a1
Bug 1198673 - Fix bug in parseModule() error handling r=jandem
js/src/jit-test/tests/modules/bug1198673.js
js/src/shell/js.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/modules/bug1198673.js
@@ -0,0 +1,2 @@
+// |jit-test| error: expected string to compile
+parseModule((1));
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3069,18 +3069,18 @@ ParseModule(JSContext* cx, unsigned argc
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() < 1) {
         JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
                              JSMSG_MORE_ARGS_NEEDED, "parseModule", "0", "s");
         return false;
     }
     if (!args[0].isString()) {
-        JS_ReportError(cx, "expected string to compile, got %s",
-                       JS_TypeOfValue(cx, args[0]));
+        const char* typeName = InformalValueTypeName(args[0]);
+        JS_ReportError(cx, "expected string to compile, got %s", typeName);
         return false;
     }
 
     RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
     JSFlatString* scriptContents = args[0].toString()->ensureFlat(cx);
     if (!scriptContents)
         return false;