(* test_error.ld —— VML 跨语言「诊断」判据(**故意编不过**) * test_error.ld - VML cross-language "diagnostics" criterion (**fails to compile on purpose**) * * ⚠ 这是**刻意的诊断用例**,不参与任何「编译通过性」检查 * ⚠ This is a **deliberate diagnostics case**; it takes part in no "does it compile" check * (`vml-out-probe` 那套逐字节比对跑的是同目录的 out.*,别把本文件混进去)。 * (the byte-for-byte comparison run by `vml-out-probe` uses the out.* files in this same * directory - don't mix this file into that set.) * 用途:验证 error / warning 的报出与要素(文件 / 行 / 列 / 诊断码)+ 编辑器气泡。 * Purpose: verify how errors / warnings are reported and that every part is present * (file / line / column / diagnostic code) + the editor bubble. * 期望产出:1 个 warning + 1 个 error,两者要素齐全。 * Expected output: 1 warning + 1 error, both with every part present. * * ⚠ **warning 刻意用「缺失头文件」造**:预处理器那条 `[Preprocessor_IncludeNotFound]`(1201) * ⚠ The **warning is deliberately produced by a "missing header file"**: that * `[Preprocessor_IncludeNotFound]` (1201) preprocessor diagnostic * 是**默认就开**的真诊断,自带 文件:行 + 诊断码;它只产 warning、不产 error —— * is a **real** one that is **on by default**, and it carries file:line + a diagnostic code; * it produces only a warning, never an error - * 本文件的 error 仍是下面那句未声明引用。「未使用变量」那类警告本前端产不出 * this file's error is still the undeclared reference below. The "unused variable" class of * warnings cannot be produced by this front end * (`WarnUnused` 全仓**只有 CCompiler 在调**,CompilerBase/CodeGeneratorBase.cs:130)。 * (`WarnUnused` is **only** called by CCompiler in the whole repo, CompilerBase/CodeGeneratorBase.cs:130). * ⚠ `.ld` 在**编译成功**时,链接器还会另打一条 `[lib-internal] 库代码里有 21 个未解析标签` * ⚠ When `.ld` **does** compile, the linker prints one more line, * `[lib-internal] 21 unresolved labels in library code` * (库档固定噪音,不是本文件的诊断 —— 本文件在代码生成阶段就失败,走不到链接器; * (fixed library-level noise, not a diagnostic of this file - this file already fails at code * generation and never reaches the linker; * 别把那条当成本用例的期望产出)。 * don't take that line as this case's expected output.) * ⚠ 注释只能用 IEC 61131-3 的 (* ... *):本前端**不认** COM / // / '。 * ⚠ Comments may only use IEC 61131-3's (* ... *): this front end **does not** accept COM / // / '. * ⚠ 与 js / lua 不同,本前端**会**检查未声明的变量 —— 走共用诊断通道 `ReportUndefined` * ⚠ Unlike js / lua, this front end **does** check undeclared variables - through the shared * diagnostics channel `ReportUndefined` * (LadderCompiler/CodeGenerator.Core.cs:615),故诊断码与列号都齐。 * (LadderCompiler/CodeGenerator.Core.cs:615), so both the diagnostic code and the column number are present. * ↳ 2026-10-04 复验仍成立:实测 1 个 warning(`test_error.ld:48: warning: 找不到头文件 "nosuchheader.h" [Preprocessor_IncludeNotFound]`) * ↳ Re-verified 2026-10-04, still holds: measured 1 warning * (`test_error.ld:48: warning: cannot find header file "nosuchheader.h" [Preprocessor_IncludeNotFound]`) * + 1 个 error(`test_error.ld:51:11: error: 未声明的变量 'undefinedValue' [CodeGen_UndefinedVariable]`),要素齐全。 * + 1 error (`test_error.ld:51:11: error: undeclared variable 'undefinedValue' [CodeGen_UndefinedVariable]`), * all parts present. *) #include BEGIN PRINT_STR "test_error.ld" PRINT_INT undefinedValue END_PROGRAM