fix(语法错误): 有模板的题报错行号多 1;else 后面写了条件被说成「少了冒号」,a+b=c 被说成「判断相等要用 ==」
全库 9182 条 Python 编译错误逐条过了一遍翻译表,1014 条的说明变了: - 行号:判题跑的是「模板 + 代码」,运行时错误扣了模板行数、编译错误没扣, 「第 N 行」和标红都落在下一行(691 条)。提交和运行例子两条路都扣上, gcc 的 main.c:N: 和代码摘录左边的行号一起扣。报错前先打了一条警告时 File 那行是缩进的,行号原来解析不出来。 - 同一句报错要看出错那一行才分得开:expected ':' 九成是 else a<60:(行尾有冒号), 「Maybe you meant '=='」只有 if / while 行才是真想判相等,a+b=c、a=96,b=92、 print(1+1=2) 各有各的说法。 - 选了 Python 却交了 C 代码(294 条),直接说换语言。只凭 printf 不算: Python 里 print 手误成 printf 的不少。 - 单独说清楚的:elif: 没写条件、esle / else if、=< 写反、条件之间用逗号、 漏了 +、√ ² ≤ ≥、顿号、全角 #、emoji(正则少了 u 标志)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f413518a85
commit
96ce9725b2
6 files changed
+132
-20
No files matched your search
@@ -4,6 +4,7 @@ import { config } from "../config"
|
||||
import { postJudge, statusValue, type JudgeCase, type JudgeResponse } from "./run"
|
||||
import { nativeRuntimeError, parsePythonTraceback } from "./runtime-diagnosis"
|
||||
import { JudgeStatus, type JudgeStatusValue } from "./status"
|
||||
import { shiftCompileLines } from "./template"
|
||||
|
||||
/**
|
||||
* 试运行:「运行例子」「自己输入」、后台「生成测试点」。
|
||||
@@ -148,7 +149,10 @@ async function judgeTrial(options: Parameters<typeof runTrial>[0]): Promise<Tria
|
||||
if (parsed.err === "CompileError") {
|
||||
return {
|
||||
status: "compile-error",
|
||||
message: typeof parsed.data === "string" ? parsed.data : "",
|
||||
message:
|
||||
typeof parsed.data === "string"
|
||||
? shiftCompileLines(parsed.data, options.prependLines)
|
||||
: "",
|
||||
}
|
||||
}
|
||||
throw new Error(`JudgeServer error ${parsed.err}: ${JSON.stringify(parsed.data)}`)
|
||||
|
||||
Reference in new issue
Block a user