## Phase 71-SSA: StageBDriverBox birth warning 解消 - Fixed false-positive dev verify warning for static boxes - StageBDriverBox is a static box, so it doesn't follow NewBox→birth pattern - Modified lifecycle.rs to skip StageBDriverBox from birth() requirement ## Phase 73-A: Stage-3 legacy ENV 統一化 - Consolidated NYASH_PARSER_STAGE3 and HAKO_PARSER_STAGE3 → NYASH_FEATURES=stage3 - Updated 20 test files (46 direct replacements) - Special handling for parser_stage3.rs compat layer and mir_static_main_args_loop.rs - All test files now use unified NYASH_FEATURES=stage3 ## Phase 72-73: ENV inventory documented - Created phase72-73-env-inventory.md with complete usage analysis - Identified 113 direct ENV reads requiring SSOT consolidation - Prioritized Phase 72 (JoinIR EXPERIMENT SSOT) and Phase 73 (Stage-3 cleanup) ## Phase 74-SSA: Minimal reproduction for static box delegation - Created parser_box_minimal.hako and ssa_static_delegation_min.hako - Investigated spawn failure in selfhost compiler (arguments too long) - Root cause: NYASH_NY_COMPILER_EMIT_ONLY=1 defaults to emit-only mode 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
119 lines
5.5 KiB
Rust
119 lines
5.5 KiB
Rust
/*!
|
||
* FuncScanner / Stage‑B 用 SSA デバッグ用テスト
|
||
*
|
||
* 目的:
|
||
* - lang/src/compiler/tests/funcscanner_fib_min.hako と同等のソースを Rust 側から
|
||
* 直接 MIR 化し、MirVerifier 経由で UndefinedValue / DominatorViolation を観測する。
|
||
* - CLI 実行ログではノイズが多くなるため、ここでは純粋に MIR モジュール単体に対する
|
||
* verify 結果と、ssa.rs 側の `[ssa-undef-debug]` ログだけにフォーカスする。
|
||
*
|
||
* 注意:
|
||
* - 現時点では FuncScannerBox.scan_all_boxes/1 まわりに既知の UndefinedValue があるため
|
||
* このテストは #[ignore] 付き(デバッグ専用)だよ。
|
||
* - 修正が完了して UndefinedValue が出なくなったら、将来的に #[ignore] を外すか、
|
||
* ベースラインフィルタを挟んで常時検証テストへ昇格させる想定。
|
||
*/
|
||
|
||
use crate::ast::ASTNode;
|
||
use crate::mir::{MirCompiler, MirPrinter, MirVerifier};
|
||
use crate::parser::NyashParser;
|
||
|
||
fn ensure_stage3_env() {
|
||
std::env::set_var("NYASH_FEATURES", "stage3");
|
||
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
|
||
std::env::set_var("NYASH_ENABLE_USING", "1");
|
||
}
|
||
|
||
/// FuncScannerBox.scan_all_boxes/1 + LoopForm v2 最小ケース(fib)の SSA デバッグ
|
||
///
|
||
/// - 入力ソースは lang/src/compiler/tests/funcscanner_fib_min.hako と同一。
|
||
/// - main 内で static box TestBox/Main を組み立てて FuncScannerBox.scan_all_boxes(src) を呼ぶ。
|
||
/// - MirVerifier の UndefinedValue を拾いつつ、ssa.rs 側の `[ssa-undef-debug]` ログで
|
||
/// どの命令が %0 や未定義 ValueId を使っているかを観測する。
|
||
#[test]
|
||
#[ignore]
|
||
fn mir_funcscanner_fib_min_ssa_debug() {
|
||
ensure_stage3_env();
|
||
|
||
// funcscanner_fib_min.hako と同じソースをそのまま使う
|
||
let src = include_str!("../../lang/src/compiler/tests/funcscanner_fib_min.hako");
|
||
let ast: ASTNode =
|
||
NyashParser::parse_from_string(src).expect("parse funcscanner_fib_min.hako ok");
|
||
|
||
let mut mc = MirCompiler::with_options(false);
|
||
let cr = mc
|
||
.compile(ast)
|
||
.expect("compile funcscanner_fib_min.hako ok");
|
||
|
||
let mut verifier = MirVerifier::new();
|
||
if let Err(errors) = verifier.verify_module(&cr.module) {
|
||
// デバッグ時に MIR 全体を見たい場合は NYASH_MIR_TEST_DUMP=1 で有効化
|
||
if std::env::var("NYASH_MIR_TEST_DUMP").ok().as_deref() == Some("1") {
|
||
let dump = MirPrinter::new().print_module(&cr.module);
|
||
eprintln!("----- MIR DUMP (FuncScanner.fib_min) -----\n{}", dump);
|
||
}
|
||
|
||
for e in &errors {
|
||
eprintln!("[rust-mir-verify] {}", e);
|
||
}
|
||
panic!("MIR verification failed for funcscanner_fib_min (debug harness)");
|
||
}
|
||
}
|
||
|
||
/// FuncScannerBox._scan_methods/4 + _parse_params/_trim の最小ケース(TestBox 本文だけ)の SSA デバッグ
|
||
///
|
||
/// - 入力ソースは lang/src/compiler/tests/funcscanner_scan_methods_min.hako と同一。
|
||
/// - main 内で TestBox/Main 相当のソースを組み立て、FuncScannerBox._find_matching_brace で
|
||
/// TestBox 本文だけを抜き出してから FuncScannerBox._scan_methods を直接呼ぶ。
|
||
/// - UndefinedValue が出ないこと(特に _parse_params / _trim 呼び出しで未定義の me/receiver が使われないこと)
|
||
/// を MirVerifier で確認する。
|
||
#[test]
|
||
fn mir_funcscanner_scan_methods_ssa_debug() {
|
||
ensure_stage3_env();
|
||
|
||
let src = include_str!("../../lang/src/compiler/tests/funcscanner_scan_methods_min.hako");
|
||
let ast: ASTNode =
|
||
NyashParser::parse_from_string(src).expect("parse funcscanner_scan_methods_min.hako ok");
|
||
|
||
let mut mc = MirCompiler::with_options(false);
|
||
let cr = mc
|
||
.compile(ast)
|
||
.expect("compile funcscanner_scan_methods_min.hako ok");
|
||
|
||
let mut verifier = MirVerifier::new();
|
||
if let Err(errors) = verifier.verify_module(&cr.module) {
|
||
if std::env::var("NYASH_MIR_TEST_DUMP").ok().as_deref() == Some("1") {
|
||
let dump = MirPrinter::new().print_module(&cr.module);
|
||
eprintln!(
|
||
"----- MIR DUMP (FuncScanner.scan_methods_min) -----\n{}",
|
||
dump
|
||
);
|
||
}
|
||
for e in &errors {
|
||
eprintln!("[rust-mir-verify] {}", e);
|
||
}
|
||
panic!("MIR verification failed for funcscanner_scan_methods_min (debug harness)");
|
||
}
|
||
}
|
||
|
||
/// Dev-only: FuncScannerBox.skip_whitespace/2 の VM 実行観測テスト
|
||
///
|
||
/// - Option C (LoopForm v2 + LoopSnapshotMergeBox + BTree* 化) 適用後、
|
||
/// 267/268 テストは安定して緑になっているが、このテストだけ
|
||
/// ValueId / BasicBlockId の非決定的な揺れが残っている。
|
||
/// - 根本原因は variable_map(HashMap<String, ValueId>) の順序非決定性
|
||
/// に起因する可能性が高く、Phase 25.3 では「既知の flakiness」として扱う。
|
||
/// - 後続フェーズ(BoxCompilationContext / variable_map の BTreeMap 化)で
|
||
/// 構造的に解消する予定のため、ここでは #[ignore] で通常テストから外す。
|
||
#[test]
|
||
#[ignore]
|
||
fn mir_funcscanner_skip_ws_vm_debug_flaky() {
|
||
// このテストは、FuncScannerBox.skip_whitespace/2 を経由する最小ケースを
|
||
// VM + NYASH_MIR_DEBUG_LOG 付きで実行し、__mir__ ログから挙動を目視確認するための
|
||
// 開発用ハーネスとして残しておく。
|
||
//
|
||
// 実装詳細は tools 側の専用ハーネスおよび
|
||
// docs/private/roadmap2/phases/phase-25.3-funcscanner/README.md を参照。
|
||
assert!(true, "dev-only flaky test placeholder");
|
||
}
|