fix(parse): 孤立 * 行不再 panic(exit 101 → 干净诊断)
qdagent 全仓 labels 扫描期间实测:任何 .mq.md 里有一行只含单个 `*`
(markdown 强调残留)时,`*…* = 返回` 分支同时满足 starts_with/ends_with('*'),
切片 &trimmed[1..0] 越界,整条 labels 扫描被一个文件打死(exit 101)。
修复:斜体返回分支要求 len >= 2,裸 `*` 落回 "unrecognized statement"
干净错误而非崩溃。
实测:
- tests/errors/lone-asterisk.mq.md → check 报 "unrecognized statement: *",
exit 1(不再 101)
- gold 回归 error_lone_asterisk_line 通过
- cargo test --release 全套件 0 failed
This commit is contained in:
1 parent
bf76e069ee
commit
bcfc763ba4
3 files changed
+27
-2
No files matched your search
+6
-2
@@ -444,8 +444,12 @@ impl<'a> Cursor<'a> {
|
||||
);
|
||||
}
|
||||
|
||||
// v0.3: *…* = return
|
||||
if trimmed.starts_with('*') && trimmed.ends_with('*') && !trimmed.starts_with("**") {
|
||||
// v0.3: *…* = return. A lone `*` (markdown emphasis leftover) must NOT
|
||||
// enter this branch: it both starts and ends with `*`, and the slice
|
||||
// below would panic (`[1..0]`). Require a real opener+closer pair; a
|
||||
// bare `*` falls through to the ordinary statement error / narration
|
||||
// handling instead of crashing the whole process.
|
||||
if trimmed.starts_with('*') && trimmed.ends_with('*') && trimmed.len() >= 2 && !trimmed.starts_with("**") {
|
||||
let inner = &trimmed[1..trimmed.len() - 1];
|
||||
return stmt_from_italic_return(inner, span);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user