Skip to content

Commit 2923398

Browse files
ntreldlang-bot
authored andcommitted
Fix Issue 23426 - Example Run button shows wrong line numbers for errors
1 parent d6fa144 commit 2923398

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

js/run.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ function wrapIntoMain(code) {
190190
var codeOut = "void main()\n{\n";
191191
// writing to the stdout is probably often used
192192
codeOut += " import std.stdio: write, writeln, writef, writefln;\n ";
193+
codeOut += "#line 1\n";
193194
codeOut += code.split("\n").join("\n ");
194195
codeOut += "\n}";
195196
return codeOut;

js/run_examples.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ function wrapIntoMain(code) {
2222
// dynamically wrap into main if needed
2323
if (code.indexOf("void main") >= 0) {
2424
codeOut = "import " + currentPackage + "; ";
25+
codeOut += "#line 1\n";
2526
codeOut += code;
2627
}
2728
else {
2829
var codeOut = "void main()\n{\n";
2930
codeOut += " import " + currentPackage + ";\n";
3031
// writing to the stdout is probably often used
3132
codeOut += (currentPackage == "std.file") ? " import std.stdio: writeln, writef, writefln;\n " : " import std.stdio: write, writeln, writef, writefln;\n ";
33+
codeOut += "#line 1\n";
3234
codeOut += code.split("\n").join("\n ");
3335
codeOut += "\n}";
3436
}

0 commit comments

Comments
 (0)