From f58f0c12c68c55ab020aab2c5f702c846b9f2adc Mon Sep 17 00:00:00 2001 From: daurnimator Date: Mon, 22 May 2017 00:23:13 +1000 Subject: src/lparser.js: create error message using luaO_pushfstring Fixes issue where 'what' is a lua string (not a JS string) --- src/lparser.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lparser.js b/src/lparser.js index 7d99f7d..100342a 100644 --- a/src/lparser.js +++ b/src/lparser.js @@ -171,9 +171,12 @@ const error_expected = function(ls, token) { const errorlimit = function(fs, limit, what) { let L = fs.ls.L; let line = fs.f.linedefined; - let where = (line === 0) ? "main function" : `function at line ${line}`; - let msg = `too many ${what} (limit is ${limit}) in ${where}`; - llex.luaX_syntaxerror(fs.ls, defs.to_luastring(msg)); + let where = (line === 0) + ? defs.to_luastring("main function", true) + : lobject.luaO_pushfstring(L, defs.to_luastring("function at line %d", true), line); + let msg = lobject.luaO_pushfstring(L, defs.to_luastring("too many %s (limit is %d) in %s", true), + what, limit, where); + llex.luaX_syntaxerror(fs.ls, msg); }; const checklimit = function(fs, v, l, what) { -- cgit v1.2.3-54-g00ecf