mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 17:06:39 +00:00
Fix off-by-one line number in JS error reporting.
Post SM60 upgrade, CompileFunction started actually adding a line in front of the source buffer, shifting the error reporting in the simulation and other callers of LoadScript. The GUI isn't affected as it uses LoadGlobalScript, which uses Evaluate directly. Refs #5859 Fixes #5895 Differential Revision: https://code.wildfiregames.com/D3257 This was SVN commit r24455.
This commit is contained in:
@@ -807,7 +807,10 @@ bool ScriptInterface::LoadScript(const VfsPath& filename, const std::string& cod
|
||||
std::string filenameStr = filename.string8();
|
||||
|
||||
JS::CompileOptions options(rq.cx);
|
||||
options.setFileAndLine(filenameStr.c_str(), 1);
|
||||
// Set the line to 0 because CompileFunction silently adds a `(function() {` as the first line,
|
||||
// and errors get misreported.
|
||||
// TODO: it would probably be better to not implicitly introduce JS scopes.
|
||||
options.setFileAndLine(filenameStr.c_str(), 0);
|
||||
options.setIsRunOnce(false);
|
||||
|
||||
JS::SourceText<mozilla::Utf8Unit> src;
|
||||
|
||||
Reference in New Issue
Block a user