fix: 解析不可恢复错误透传 oxc 真实诊断并补 concise 箭头体回归钉

This commit is contained in:
2026-09-14 14:53:55 +00:00
parent d161b7cfe3
commit 2598c2647b
2 changed files with 35 additions and 1 deletions
+29
View File
@@ -49,3 +49,32 @@ fn parse_multiple_statements() {
let program = result.unwrap();
assert_eq!(program.body.len(), 3, "should have 3 statements");
}
#[test]
fn parse_concise_arrow_array_member_call() {
// concise 箭头体 + 数组字面量 + 成员调用形是合法 JS:必须解析成功。
let allocator = Allocator::default();
let result = oxide_parser::parse(&allocator, "() => [1, 2].join('|')");
assert!(result.is_ok(), "concise 箭头体数组成员调用形应解析成功,实际错误:{:?}", result.err());
}
#[test]
fn parse_concise_arrow_iife_with_kind_helper() {
// 顶层 kind 助手 + concise IIFE 九元素数组 .join('|') 形(事故测试源形态复刻):
// 必须解析成功;若解析失败,错误消息应携带定位到具体出错 token 的诊断。
let allocator = Allocator::default();
let source = "const kind = (fn) => { try { fn(); return 'no'; } catch (e) { return e.constructor.name; } };
(() => [
kind(() => new Temporal.PlainDate(2020n, 1, 1)),
kind(() => new Temporal.PlainDate(Symbol(), 1, 1)),
kind(() => new Temporal.PlainDate(undefined, 1, 1)),
kind(() => new Temporal.PlainDate(2020, 'invalid', 1)),
kind(() => new Temporal.PlainDate(Infinity, 1, 1)),
kind(() => new Temporal.PlainDate(2020, 1, -Infinity)),
kind(() => new Temporal.PlainDate()),
kind(() => new Temporal.PlainDate(2021)),
kind(() => Temporal.PlainDate(2020, 1, 1)),
].join('|'))()";
let result = oxide_parser::parse(&allocator, source);
assert!(result.is_ok(), "concise IIFE 九元素数组 join 形应解析成功,实际错误:{:?}", result.err());
}