1
0
Fork 0
mirror of https://github.com/imjasonh/nescript synced 2026-07-18 06:36:57 +00:00

Analyzer: E0301 error on RAM exhaustion

The linear RAM allocator now checks for overflow. The zero-page region
is capped at \$80 (leaving \$80-\$FF for IR codegen temp slots), and the
main RAM allocator stops at \$0800 (end of NES internal RAM). Overflow
emits E0301 with a helpful note pointing at the declaration.

https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
Claude 2026-04-12 11:05:13 +00:00
parent 1e4e384501
commit e688397594
No known key found for this signature in database
3 changed files with 72 additions and 11 deletions

View file

@ -298,6 +298,24 @@ fn analyze_return_wrong_type() {
);
}
#[test]
fn analyze_ram_overflow_emits_e0301() {
// Two arrays totalling >2 KB cannot fit in NES RAM, triggering
// E0301 at allocation time.
let src = r#"
game "Test" { mapper: NROM }
var huge: u8[2000]
var also_huge: u8[2000]
on frame { wait_frame }
start Main
"#;
let errors = analyze_errors(src);
assert!(
errors.contains(&ErrorCode::E0301),
"RAM overflow should produce E0301, got: {errors:?}"
);
}
#[test]
fn analyze_expensive_multiply_warns() {
let errors = analyze_errors(