diff --git a/src/plugins/qtscripteditor/parser/javascript.g b/src/plugins/qtscripteditor/parser/javascript.g
index f762498ee4c60cd19f3f2edd9e950735be84e791..80dfaddcad47229393aa98547e152568b8a3897f 100644
--- a/src/plugins/qtscripteditor/parser/javascript.g
+++ b/src/plugins/qtscripteditor/parser/javascript.g
@@ -2179,7 +2179,7 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ;
             }
         }
 
-        const QString msg = QString::fromUtf8("Unexpected token: `%1'").arg(token_buffer[0].token);
+        const QString msg = QString::fromUtf8("Unexpected token: `%1'").arg(spell[token_buffer[0].token]);
         diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error,
             token_buffer[0].loc.startLine, token_buffer[0].loc.startColumn, msg));
     }
diff --git a/src/plugins/qtscripteditor/parser/javascriptparser.cpp b/src/plugins/qtscripteditor/parser/javascriptparser.cpp
index 794c416b763c8f3aeca13a92420df57a22c8b7ae..ac8eabf09548eed7b35f30958996d69b6c0bf8cc 100644
--- a/src/plugins/qtscripteditor/parser/javascriptparser.cpp
+++ b/src/plugins/qtscripteditor/parser/javascriptparser.cpp
@@ -1184,7 +1184,7 @@ case 266: {
             }
         }
 
-        const QString msg = QString::fromUtf8("Unexpected token: `%1'").arg(token_buffer[0].token);
+        const QString msg = QString::fromUtf8("Unexpected token: `%1'").arg(spell[token_buffer[0].token]);
         diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error,
             token_buffer[0].loc.startLine, token_buffer[0].loc.startColumn, msg));
     }