## Major Features Added
### Field Visibility System
- Added `private { ... }` and `public { ... }` blocks in box declarations
- Default visibility is now handled explicitly (fields must be in either block)
- Visibility checks enforced at both interpreter and VM levels
### Parser Enhancements
- Extended AST with public_fields and private_fields vectors
- Added parsing for visibility blocks in box definitions
- Maintained backward compatibility with existing `init { ... }` syntax
### Interpreter Implementation
- Added visibility checks in field access (get_field/set_field)
- External access to private fields now throws appropriate errors
- Internal access (within methods) always allowed
### VM Implementation
- Extended VM with object_class tracking for visibility checks
- RefGet/RefSet instructions now enforce field visibility
- Fixed nested box declaration collection (boxes defined inside methods)
### Test Examples Added
- docs/examples/visibility_ok.nyash - demonstrates correct usage
- docs/examples/visibility_error.nyash - tests private field access errors
## Technical Details
### Error Messages
- Interpreter: "Field 'X' is private in Y"
- VM: Same error message for consistency
### Current Limitations
- All RefGet/RefSet treated as external access in VM (internal flag future work)
- Legacy `init { ... }` fields treated as having unspecified visibility
## Test Results
✅ Interpreter: Both test cases pass correctly
✅ VM: Both test cases pass correctly after nested declaration fix
This implements the foundation for proper encapsulation in Nyash,
following the "explicit is better than implicit" philosophy.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
📚 Nyash Documentation
🚀 はじめに
📂 新しいドキュメント構造(2025年8月20日再編成)
📖 reference/ - 正式な技術仕様
- language/ - 言語仕様(構文、型システム、Box仕様)
- architecture/ - システムアーキテクチャ(MIR、VM、実行バックエンド)
- api/ - ビルトインBoxのAPI仕様
- plugin-system/ - プラグインシステム、BID-FFI仕様
📚 guides/ - 利用者向けガイド
- getting-started.md - はじめに(統一版)
- tutorials/ - ステップバイステップのチュートリアル
- examples/ - 実践的なサンプルコード
- wasm-guide/ - WebAssemblyビルドガイド
🔧 development/ - 開発者向け
- current/ - 現在進行中のタスク(CURRENT_TASK.md等)
- roadmap/ - 開発計画
- phases/ - Phase 8~10の詳細計画
- native-plan/ - ネイティブビルド計画
- proposals/ - RFC、新機能提案
🗄️ archive/ - アーカイブ
- consultations/ - AI相談記録(gemini/chatgpt/codex)
- decisions/ - 過去の設計決定
- build-logs/ - ビルドログ、ベンチマーク結果
- old-versions/ - 古いドキュメント
🎯 クイックアクセス
すぐ始める
技術リファレンス
開発状況
📋 再編成について
ドキュメントは2025年8月20日に再編成されました。詳細はREORGANIZATION_REPORT.mdを参照してください。
旧パスから新パスへの主な変更:
説明書/→guides/とreference/に分割予定/→development/roadmap/- 散在していたファイル → 適切なカテゴリに整理
Nyash は「Everything is Box」哲学に基づく言語です。詳細はコア概念とガイドを参照してください。