Files
hakorune/apps/tests/phase285_weak_basic.hako
tomoaki ab76e39036 feat(parser): Phase 285A1.4 & A1.5 - Weak field sugar + Parser hang fix
A1.4: Add sugar syntax `public weak parent` ≡ `public { weak parent }`
A1.5: Fix parser hang on unsupported `param: Type` syntax

Key changes:
- A1.4: Extend visibility parser to handle weak modifier (fields.rs)
- A1.5: Shared helper `parse_param_name_list()` with progress-zero detection
- A1.5: Fix 6 vulnerable parameter parsing loops (methods, constructors, functions)
- Tests: Sugar syntax (OK/NG), parser hang (timeout-based)
- Docs: lifecycle.md, EBNF.md, phase-285a1-boxification.md

Additional changes:
- weak() builtin implementation (handlers/weak.rs)
- Leak tracking improvements (leak_tracker.rs)
- Documentation updates (lifecycle, types, memory-finalization, etc.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-24 07:44:50 +09:00

36 lines
932 B
Plaintext

// Phase 285A0.1: WeakRef basic test
// SSOT: docs/reference/language/lifecycle.md:179 - weak(x)/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 box
if y.x != 42 {
print("ng: weak_to_strong value differs from original")
return 1
}
print("ok: weak and weak_to_strong work correctly")
return 0
}
}