mirror of
https://github.com/imjasonh/nescript
synced 2026-07-14 11:36:40 +00:00
Analyzer: W0102 warn on infinite loop without yield
Emits W0102 when a \`loop\` body contains no \`break\`, \`return\`, \`transition\`, or \`wait_frame\`, since such loops spin forever and prevent vblank from being handled. The check recurses into nested if/while bodies so that \`break\` behind a condition still counts. https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
parent
6f0e4a0a74
commit
21a74652f2
3 changed files with 98 additions and 2 deletions
|
|
@ -45,7 +45,6 @@ pub enum ErrorCode {
|
|||
// W01xx: Warnings
|
||||
#[allow(dead_code)]
|
||||
W0101, // expensive multiply/divide operation
|
||||
#[allow(dead_code)]
|
||||
W0102, // loop without break or wait_frame
|
||||
W0103, // unused variable
|
||||
W0104, // unreachable state
|
||||
|
|
@ -118,6 +117,13 @@ impl Diagnostic {
|
|||
}
|
||||
}
|
||||
|
||||
/// Construct a diagnostic with the level implied by the code
|
||||
/// (identical to [`Diagnostic::error`], but reads better at call
|
||||
/// sites that emit a warning code).
|
||||
pub fn warning(code: ErrorCode, message: impl Into<String>, span: Span) -> Self {
|
||||
Self::error(code, message, span)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_help(mut self, help: impl Into<String>) -> Self {
|
||||
self.help = Some(help.into());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue