amber-lang / amber-lang/amber

Extend control-flow termination analysis to loops

オープン
#1,144 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
5.2k
フォーク
145
平均マージ
5日 3時間
マージ済み PR(30日)
7

説明

## Description

PR #1139 introduced control-flow termination analysis and stops translating a block after a terminating statement. The current implementation covers direct termination (`return`, `exit`, and `fail`) and conditional constructs, but loop-related control flow still needs dedicated handling.

Follow-up to:
- #1139
- https://github.com/amber-lang/amber/pull/1139#discussion_r3590029161
- https://github.com/amber-lang/amber/pull/1139#discussion_r3629492084

## Scope

Extend termination analysis to cover:

- `InfiniteLoop`
- `WhileLoop`
- `IteratorLoop`
- loop bodies and nested blocks
- `break` and `continue`, with behavior evaluated in the context of their enclosing loop
- `CommandModifier` blocks where applicable

The analysis should distinguish between terminating the current block/function and only changing control flow within a loop. In particular, `break` and `continue` must not be treated like unconditional function-level termination outside the correct loop context.

## Acceptance criteria

- Loop syntax modules participate in control-flow analysis.
- Nested loop blocks are analyzed correctly.
- `break` and `continue` are handled according to their enclosing loop.
- Translation does not incorrectly remove reachable statements after a loop.
- Tests cover infinite, while, and iterator loops, including nested conditionals and `break`/`continue` paths.
- Existing control-flow behavior introduced in #1139 remains covered by tests.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。