Bug 1225346 - Fix parseModule() error handling r=terrence
authorJon Coppeard <jcoppeard@mozilla.com>
Wed, 18 Nov 2015 16:07:18 +0000
changeset 273099 22210e87317875949f2e9e830e73b41f4680a1b0
parent 273098 c80578717b7c819f65c89d88feeedc124b7defea
child 273100 cfc8f256cea03a2d930f4a65cbabcfd5652e7dcc
push id68161
push userjcoppeard@mozilla.com
push dateWed, 18 Nov 2015 16:07:59 +0000
treeherdermozilla-inbound@22210e873178 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1225346
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1225346 - Fix parseModule() error handling r=terrence
js/src/jit-test/tests/modules/bug-1225346.js
js/src/shell/js.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/modules/bug-1225346.js
@@ -0,0 +1,2 @@
+// |jit-test| error: Error: expected filename string, got number
+parseModule("", 3);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3310,18 +3310,18 @@ ParseModule(JSContext* cx, unsigned argc
     JSFlatString* scriptContents = args[0].toString()->ensureFlat(cx);
     if (!scriptContents)
         return false;
 
     mozilla::UniquePtr<char, JS::FreePolicy> filename;
     CompileOptions options(cx);
     if (args.length() > 1) {
         if (!args[1].isString()) {
-            JS_ReportError(cx, "expected filename string, got %s",
-                           JS_TypeOfValue(cx, args[1]));
+            const char* typeName = InformalValueTypeName(args[1]);
+            JS_ReportError(cx, "expected filename string, got %s", typeName);
             return false;
         }
 
         RootedString str(cx, args[1].toString());
         filename.reset(JS_EncodeString(cx, str));
         if (!filename)
             return false;