docs/current/07-质量与裁定/moonc警告全表20261009.md
GitHub ↗
当前有效

moonc 警告全表(2026-10-09 留档)

1139 字·约 3 分钟 阅读 2026-10-10 17:07

来源:moonc check -warn-help(moonbit 工具链官方输出,93 项 + all 汇总项)。 再生:cd moonbit && moonc check -warn-help。若工具链升级后表变,以再生命令输出为准并更新本档。 三态:warn = 默认启用 · error = 默认即强制 · off = 默认关闭(+/@/- 可改)。 --warn-list 语法:+<spec> 启用 / -<spec> 关闭 / @<spec> 启用并升为错误 / <num> 单号 / <n>..<m> 区间。

与本仓的关系

  • 消警与严格度开启的总账 issue:#54(Part A 清零批 / Part B 严格度路线)。
  • as_of 2026-10-09(A1 机械批落盘后):moon check --target all = 310 条,分布 0079×217(永久豁免)/ 0035×26(归 #46 合并处置)/ 0020×18(inspect 系测试 API 依赖 core 旧 trait——迁移期噪音豁免,见 moonbit/AGENTS.md 发布流程注)/ 0029×17、0002×12、0001×10、0007×6(A3 人工判断批待办)/ 0050×2(有意遮蔽,登记 core 升级时复核)。
  • 本表存在的意义:Part B 按 @<spec> 升错误时需要官方 id/mnemonic 对照,避免每次现查。

全表

mnemonic                   description                                                     id state
unused_value               Unused variable or function.                                     1 warn
unused_value               Unused variable.                                                 2 warn
unused_type_declaration    Unused type declaration.                                         3 warn
missing_priv               Unused abstract type.                                             4 warn
unused_type_variable       Unused type variable.                                             5 warn
unused_constructor         Unused constructor.                                               6 warn
unused_field               Unused field or constructor argument.                             7 warn
redundant_modifier         Redundant modifier.                                               8 warn
struct_never_constructed   Struct never constructed.                                         9 warn
unused_pattern             Unused pattern.                                                  10 warn
partial_match              Partial pattern matching.                                        11 error
unreachable_code           Unreachable code.                                                12 warn
unresolved_type_variable   Unresolved type variable.                                        13 warn
alert or alert_<category>  All alerts or alerts with specific category.                    14 warn
unused_mut                 Unused mutability.                                               15 error
parser_inconsistency       Parser inconsistency check.                                      16 warn
ambiguous_loop_argument    Ambiguous usage of loop argument.                                17 warn
useless_loop               Useless loop expression.                                         18 warn
deprecated                 Deprecated API usage.                                            20 warn
missing_pattern_arguments  Some arguments of constructor are omitted in pattern.           21 warn
ambiguous_block            Ambiguous block.                                                 22 warn
unused_try                 Useless try expression.                                          23 warn
unused_error_type          Useless error type.                                              24 warn
test_unqualified_package   Using implicitly imported API in test.                           25 warn
unused_catch_all           Useless catch all.                                               26 warn
deprecated_syntax          Deprecated syntax.                                               27 warn
todo                       Todo                                                             28 warn
unused_package             Unused package.                                                  29 warn
missing_package_alias      Empty package alias.                                             30 warn
unused_optional_argument   Optional argument never supplied.                                31 off
unused_default_value       Default value of optional argument never used.                  32 off
text_segment_excceed       Text segment exceed the line or column limits.                  33 warn
implicit_use_builtin       Implicit use of definitions from `moonbitlang/core/builtin`.    34 warn
reserved_keyword           Reserved keyword.                                                35 warn
block_label_shadowing      Block label shadows another label.                              36 warn
unused_block_label         Unused block label.                                              37 warn
missing_invariant          For-loop is missing an invariant.                               38 off
missing_reasoning          For-loop is missing a proof_reasoning.                          39 off
multiline_string_escape    Deprecated escape sequence in multiline string.                 40 error
missing_rest_mark          Missing `..` in map pattern.                                     41 warn
invalid_attribute          Invalid attribute.                                               42 warn
unused_attribute           Unused attribute.                                                43 warn
invalid_inline_wasm        Invalid inline-wasm.                                             44 error
unused_rest_mark           Useless `..` in pattern                                          46 warn
missing_definition         Unused pub definition because it does not exist in mbti file.   49 warn
method_shadowing           Local method shadows upstream method                             50 warn
ambiguous_precedence       Ambiguous operator precedence                                   51 warn
unused_loop_variable       Loop variable not updated in loop                               52 warn
unused_trait_bound         Unused trait bound                                              53 warn
ambiguous_range_direction  Ambiguous looping direction for range e1..=e2                   54 off
unannotated_ffi            Unannotated FFI param type                                       55 error
missing_pattern_field      Missing field in struct pattern                                 56 warn
missing_pattern_payload    Constructor pattern expect payload                              57 warn
unaligned_byte_access      Unaligned byte access in bits pattern                           59 warn
unused_struct_update       Unused struct update                                             60 warn
duplicate_test             Duplicate test name                                              61 warn
invalid_cascade            Calling method with non-unit return type via `..`               62 warn
syntax_lint                Syntax lint warning                                              63 warn
unannotated_toplevel_array Unannotated toplevel array                                      64 warn
prefer_readonly_array      Suggest ReadOnlyArray for read-only array literal               65 off
prefer_fixed_array         Suggest FixedArray for mutated array literal                    66 off
unused_async               Useless `async` annotation                                       67 warn
declaration_unimplemented  Declaration is unimplemented                                    68 warn
declaration_implemented    Declaration is already implemented                              69 off
deprecated_for_in_method   using `iterator()` method for `for .. in` loop.                 70 off
core_package_not_imported  Packages in `moonbitlang/core` need to be explicitly imported.  71 warn
unqualified_local_using    unqualified local using                                          72 off
unnecessary_annotation     unnecessary type annotation                                      73 off
missing_doc                Missing documentation for public definition                     74 off
unnecessary_view_op        Unnecessary `[:]` view operator                                 75 off
result_error_return        Using `Result[T, E]` where `E` is an error type.                78 off
implicit_impl_as_method    `impl` implicitly promoted as method                             79 warn
regex_match_missing_before Missing `before` binding in `regex match`.                      80 warn
regex_match_missing_after  Missing `after` binding in `regex match`.                        81 warn
ambiguous_braces           Ambiguous `{}` braces.                                           82 warn
type_param_method          Calling method of type parameter in a deprecated way.           83 warn
unqualified_record         Struct literal in a `let` binding without a type prefix.        84 off
unlabelled_break_in_labelled_loop Unlabelled `break` directly inside a labelled loop.             85 warn
unlabelled_continue_in_labelled_loop Unlabelled `continue` directly inside a labelled loop.          86 warn
guard_inexhaustive         `guard` condition is not exhaustive and may panic.              87 warn
guard_redundant_bang       Redundant `!` on an exhaustive `guard`.                         88 warn
guard_redundant_else       Redundant `else` on an exhaustive `guard`.                      89 warn
unused_lexcase             `lexmatch`/`lexscan` branch that can never be selected because other branches takes precedence or its pattern matches nothing.  90 warn
unused_errdefer            unused `errdefer` statement                                     91 warn
fragile_catch_all          fragile `catch` handler that can be converted to `defer` or `errdefer`  92 warn
unknown_constr_pat_on_exhaustive_type using `TypeName::..` pattern on a type not marked with `#non_exhaustive`  93 warn

(all 汇总项与 note: default alert exceptions: alert_unsafe=off 为官方表尾原文。)