E4188#
Compiler diagnostic name: async_with_error_poly.
async 函数不能使用错误多态。
MoonBit 目前不支持将 async 与 raise? 结合使用。async 函数默认可能抛出错误,因此当函数可能抛错时请使用普通的 async fn;如果函数并不需要异步行为,则移除 async。
错误示例#
下面的函数同时使用了 async 和 raise?:
///|
async fn load() -> Unit raise? {
()
}
///|
test {
ignore(load)
}
MoonBit 会报告一个错误。
建议#
从异步函数中移除 raise?;如果函数不需要异步行为,则移除 async:
///|
fn load() -> Unit {
()
}
///|
test {
ignore(load)
}