agentsclimarketplace

3 debug errors

Skill morning-start/agent-skills/lang/moonbit/skills/3-debug-errors

AI 编程助手的专业技能库,涵盖 30+ 技能,按 6 类组织

Install
npx -y skills add morning-start/agent-skills --skill 3-debug-errors

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

诊断修复 MoonBit 编译错误和运行时问题。错误码速查、陷阱识别、修复验证。 Use when encountering compilation errors, warnings, or runtime issues, error codes like E0015/E0029/E3002/E4036 etc.

SKILL.md

3.6 KB, as published. Nobody here has run it

诊断修复 MoonBit 错误

触发条件

用户遇到编译错误、警告或运行时异常时激活。

Top 10 常见错误速查

错误码含义最常见原因修复
E0015unused_mut声明了 mut 但未重新赋值绑定改为 let
E0029unused_package存在其他编译错误导致 import 看似未使用修复底层错误
E3002Parse error语法格式错误(mut self/for 解构/match 逗号)检查具体语法
E4021unbound variableTrait 方法内未限定的标识符Trait::method()
E4036read-only type外部包无法构造 pub struct改为 pub(all)
E4051unused_mut (warn)同 E0015改为 let
E4087immutable field字段缺少 mut 声明添加 mut
E4145sealed trait无法实现 pub trait改为 pub(open)trait
E4014type mismatch类型不匹配检查解构/返回类型
WxxxWarning各种警告对照具体 warning 处理

执行步骤

Step 1: 获取完整错误列表

moon check      # 获取所有编译错误
moon fmt         # 自动修复格式问题

Step 2: 定位第一个真正错误

  • 总是从第一个真正的错误开始修复
  • 后续错误可能是级联产生的伪错误
  • 区分 Error vs Warning(Warning 不阻断编译但不应忽略)

Step 3: 查询错误码

  • 对照上表匹配错误码
  • 详细信息见 references/error-codes.md
  • 无匹配错误码?→ 可能是新版本新增,搜索官方文档

Step 4: 应用修复方案

按错误码对应的修复方式操作:

  • mut 相关 (E0015/E4051/E4087): 检查是否真的需要 let mut
  • 可见性相关 (E4036/E4145): 检查 pub vs pub(all), trait vs pub(open)trait
  • 语法相关 (E3002): 检查 mut self / for 解构 / match 分支格式
  • 作用域相关 (E4021): Trait 方法内用完全限定名

Step 5: 重新验证

moon check      # 确认错误消除
moon test       # 确保测试仍通过

循环 Step 2-5 直到 Exit code 0。

八大陷阱快速修复

#陷阱❌ 错误✅ 修复
1mut selffn method(mut self)内部 let s = self
2for 元组解构for (a,b) in arrfor p in arr { match p { (a,b) => ... }}
3Match 逗号分支A => f(); B => g(),A => { f() } B => { g() }
4构造只读类型直接构造 pub struct改 pub(all) struct
5实现密封 Trait实现 pub trait改 pub(open)trait
6Trait unboundother_method(self)@pkg::Trait::other_method(self)
7Option 冗余通配match o { Some(x)=>x; None=>(); _=>() }删除 _ 分支
8变量名混淆(f, w) => use w.0(nid, _) => use nid.0

详细知识

🔗 references/error-codes.md — 完整错误码速查与诊断工作流 🔗 references/pitfalls.md — 常见陷阱深度解析 🔗 references/type-system.md — 可见性系统详解 🔗 references/generics-traits-methods.md — Part 4.5 可变性语义

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.