mirror of
https://github.com/imjasonh/nescript
synced 2026-07-14 11:36:40 +00:00
W0110 inline fallback warning + docs refresh
W0110: when a function marked `inline` has a body shape the IR
lowerer can't splice (conditional early return, loops, nested
control flow, empty void body), the analyzer now emits a
warning at the declaration site so the declined hint is
visible instead of silently falling back to a regular JSR.
Implementation:
- New `W0110` error code in `src/errors/diagnostic.rs` (warning level).
- New `pub fn can_inline_fun(return_type, body) -> bool` in
`src/ir/lowering.rs`, extracted from the existing capture
logic so the analyzer and the IR lowerer share the same
eligibility rules and can never drift.
- New `check_inline_declinability` analyzer pass called from
the tail of `analyze_program`, mirroring the existing
`check_sprite_scanline_budget` / `check_unreachable_states`
passes. Emits W0110 with help + note text pointing at the
two accepted body shapes.
- `capture_inline_bodies` now defers to `can_inline_fun`
instead of duplicating the match pattern, so the two sides
stay in lockstep by construction.
Four regression tests in `src/analyzer/tests.rs` cover the
conditional-return and while-loop declines plus the two
accepted shapes (single-return expression, void sequence).
Example source cleanups: `wrap52` in `examples/war/deck.ne`
and `abs_diff` in both `examples/arrays_and_functions.ne` and
`examples/loop_break_continue.ne` drop the `inline` keyword.
All three were dead hints — the `inline` was being silently
declined before this change, so removing it is source-only;
the three ROMs are byte-identical, all 32 emulator goldens
still match.
Docs refresh
- `docs/language-guide.md`: rewrote the Inline Functions section
(real behaviour + W0110), added W0105/W0106/W0107/W0108/W0109/
W0110 to the warnings table, added the `debug.sprite_overflow*`
builtins + sprite-per-scanline mitigations section to the
Debug Mode docs, added a `cycle_sprites` statement entry and
cross-referenced it from `draw`.
- `docs/nes-reference.md`: fleshed out the "NEScript Memory
Usage" block with the full ZP + high-RAM layout, including
the new `$07EF` / `$07FC` / `$07FD` slots for sprite cycling
and the debug sprite-overflow telemetry.
- `docs/future-work.md`: documented all four debug query
builtins in the "What ships today" block; updated the open
"OAM allocation strategy" question to reference the shipped
`cycle_sprites` path and ask about an automatic-flicker
game attribute as a follow-up.
- `docs/architecture.md`: updated the `ir/` and `optimizer/`
module summaries to describe real inline splicing (now
in lowering, not the optimizer).
- `README.md`: reframed the `inline` bullet from "hint" to
"real splicing for single-return / void-body shapes";
expanded the debug-support bullet to mention the four
query builtins and their stripping in release builds; added
a new bullet for the three-layer sprite-per-scanline
mitigations; bumped the test count from 497 → 694; updated
the war.ne entry to mention the seven compiler bugs are all
fixed and point readers at `git log` (instead of the
deleted COMPILER_BUGS.md).
- `examples/README.md`: same `git log`-pointing rewrite for
the war.ne entry.
Deletions
- `examples/war/COMPILER_BUGS.md` is removed. All seven
catalogued bugs are fixed; the file's historical value
lives in `git log` now. Every source-code comment and doc
reference to the file has been updated to either point at
`git log` or just describe the bug in place.
Test count: 616 unit + 75 integration + 3 doctests = 694 total.
Clippy / fmt clean. 32/32 emulator goldens match.
https://claude.ai/code/session_0143dTgh3UeRrtfHgQwzcv5z
This commit is contained in:
parent
5e5bed39a5
commit
548787ac8a
18 changed files with 487 additions and 858 deletions
|
|
@ -216,10 +216,10 @@ parallel).
|
|||
- [x] Code review pass: read every file end-to-end, fix any
|
||||
mistakes found.
|
||||
|
||||
Two compiler bugs were discovered along the way and fixed in
|
||||
the same PR (E0506 too-many-params + the wide_hi map leak in IR
|
||||
lowering). Three more compiler limitations are documented in
|
||||
`COMPILER_BUGS.md` with workarounds in the war source for now.
|
||||
Seven compiler bugs were discovered along the way and all fixed
|
||||
on this branch — see `git log` for the full list. Every
|
||||
workaround that was originally in the war source has been
|
||||
reverted now that the underlying bugs are fixed.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -229,16 +229,11 @@ A few things shifted from the approved plan:
|
|||
|
||||
- **`arm_fly` is 4 params, not 6.** The 5th and 6th params
|
||||
(`fly_card`, `fly_face_up`) are written to globals at every
|
||||
call site instead, because the v0.1 ABI silently drops params
|
||||
past the 4th. The 4-param limit now produces a clean E0506
|
||||
diagnostic so future authors won't trip on it.
|
||||
- **`card` parameter in `card_rank` / `card_suit` / `draw_card_face`
|
||||
was renamed to per-function unique names** to dodge the IR
|
||||
lowering's shared-VarId issue documented in
|
||||
`COMPILER_BUGS.md` §1b. Same for `wrap52`'s `v` and the
|
||||
`push_back_*` helpers. `x` and `y` are still shared because
|
||||
they sit at the same parameter position in every helper that
|
||||
takes them, so the routed slot mapping is consistent.
|
||||
call site instead, because the v0.1 ABI only passes four
|
||||
parameters via the zero-page transport slots. The 4-param
|
||||
limit now produces a clean E0506 diagnostic so future authors
|
||||
see the error up front instead of chasing silent
|
||||
miscompiles.
|
||||
- **The `Playing` state's phase machine uses `match`, not a
|
||||
flat if-chain.** The if-chain shape allowed two phases to run
|
||||
in the same frame after a `set_phase` transition, which made
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue