Phase 285 P2: weak の意味論(weak <expr> + weak_to_strong() 成功/失敗)を integration smoke で固定 実装内容: - Fixture A(成功パターン): exit 0 → exit 2 に変更(fail=1, success=2 で明確化) - Fixture B(失敗パターン): 明示 drop (x = null) 方式で作成 - VM smoke success: PASS - LLVM smoke success: SKIP(backend unavailable) - VM/LLVM smoke fail: SKIP(hidden root 問題で理由付き) 既知の問題: - x = null で明示 drop しても weak_to_strong が成功(hidden root が strong ref を保持) - Phase 285 P2.1 (investigation) で root 保持箇所を棚卸し予定 スコープ: - Block scope drop conformance は別タスク(未整合の可能性あり) - P2 では明示 drop 方式で weak の最小意味論(non-owning)のみを検証 検証: - quick smoke 154/154 PASS 維持 - integration smoke 4本(success 2本 PASS/SKIP、fail 2本 SKIP) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
36 lines
987 B
Plaintext
36 lines
987 B
Plaintext
// Phase 285W-Syntax-0: WeakRef basic test with weak x syntax
|
|
// SSOT: docs/reference/language/lifecycle.md:179 - weak <expr>/weak_to_strong()
|
|
//
|
|
// Test: weak x creates WeakRef, weak_to_strong() returns Box when alive
|
|
// Note: Full drop semantics test deferred (needs GC/scope analysis)
|
|
// VM: PASS expected
|
|
// LLVM: SKIP (Phase 285A1)
|
|
|
|
box SomeBox {
|
|
x
|
|
}
|
|
|
|
static box Main {
|
|
main() {
|
|
local x = new SomeBox()
|
|
x.x = 42
|
|
local w = weak x
|
|
|
|
// Test 1: weak_to_strong should succeed while x is alive
|
|
local y = w.weak_to_strong()
|
|
if y == null {
|
|
print("ng: weak_to_strong returned null while x alive")
|
|
return 1
|
|
}
|
|
|
|
// Test 2: verify weak_to_strong returns same object (identity)
|
|
if y.x != 42 {
|
|
print("ng: weak_to_strong returned different object (expected x=42)")
|
|
return 1
|
|
}
|
|
|
|
print("ok: weak and weak_to_strong work correctly")
|
|
return 2
|
|
}
|
|
}
|