E4148

E4148#

循环标签未声明。

MoonBit 允许程序员使用标签继续或跳出循环。标签必须在 continuebreak 语句所在的循环之一的开头声明。

错误示例#

fn read() -> @bytes.View {
  ...
}

fn main {
  loop read() {
    [] => break
    _ => continue read~ read()
    //            ^~~~~
    // Error: The label read is undeclared.
  }
  // Defining the label here does not work since continue cannot jump to a different loop.
  read~: loop read() {
    [] => break
  }
}

建议#

请确保标签在 continuebreak 语句所在的循环之一的开头声明。

fn main {
  read~: loop read() {
    [] => break
    _ => continue read~ read()
  }
}