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:
xuyueandClaude Opus 5.5 committed 2026-09-30 10:44:09 +08:00
1 parent f413518a85
commit 96ce9725b2
6 files changed
+132 -20

No files matched your search

+4 -2
View File
@@ -14,7 +14,7 @@ import { asRecord } from "../routes/helpers"
import type { JudgeJobData } from "./job"
import { judgeConfigFor } from "./languages"
import { isAccepted, JudgeStatus, type JudgeStatusValue } from "./status"
import { parseProblemTemplate } from "./template"
import { parseProblemTemplate, shiftCompileLines } from "./template"
import { runSqlCase } from "./sql"
import {
nativeRuntimeError,
@@ -536,9 +536,11 @@ export async function judgeSubmission(job: JudgeJobData) {
let statisticInfo: Record<string, unknown> = {}
if (response.err) {
const errInfo =
typeof response.data === "string" ? response.data : JSON.stringify(response.data)
result = JudgeStatus.COMPILE_ERROR
statisticInfo = {
err_info: typeof response.data === "string" ? response.data : JSON.stringify(response.data),
err_info: shiftCompileLines(errInfo, template ? template.prepend.split("\n").length : 0),
score: 0,
}
} else {