docs: explain match assertions and annotation type distinctions

This commit is contained in:
2026-11-15 19:14:55 +08:00
parent 903b3bbf9d
commit 57cd32eb5c
16 changed files with 58 additions and 6 deletions
+2
View File
@@ -26,6 +26,7 @@ fn function_bodies_accept_method_statements_and_optional_trailing_return() {
.body
.statements
.iter()
// 两个调用都应是普通 Expression 语句,不能被误识别为返回或绑定。
.all(|s| matches!(s.kind, StmtKind::Expression(_)))
);
assert!(parse_ast("function empty(): Unit {}", ParseMode::Module).is_ok());
@@ -258,6 +259,7 @@ fn json_interfaces_reject_unknown_fields_schema_changes_and_invalid_ranges() {
kind: ExprKind::Name("値".into()),
span: Span::new(1, 3),
});
// 结构范围虽非逆序,起点切断三字节日文字符,仍须在提供原文的校验阶段失败。
assert!(matches!(
AstDocument::new(root).unwrap().validate_source("値"),
Err(AstError::InvalidSpan(_))