Phase 21.4: HC012 Dead Static Box + HC013 Duplicate Method実装完了
## 実装内容
### HC012: Dead Static Box
- 未参照static boxを検出
- IR boxes配列活用、calls情報から参照チェック
- テスト: HC012_dead_static_box/{ok,ng}.hako + expected.json
### HC013: Duplicate Method
- 同名・同arityメソッド重複検出
- Box内でメソッド署名の一意性チェック
- テスト: HC013_duplicate_method/{ok,ng}.hako + expected.json
### 🔥 Critical Bug Fix: parser_core.hako arity計算修正
- **問題**: arityが「カンマの数」を返していた(add(a,b) → 1)
- **修正**: `if any == 1 { arity = arity + 1 }` に変更
- **影響**: 全メソッドのarity計算が正しくなった(HC015等に波及)
### Infrastructure改善
- analysis_consumer.hako: _ensure_array()ヘルパー導入
- MapBox.get().push()問題の根本解決
- uses/methods/calls/boxes全てで安全なpush実現
- run_tests.sh: NYASH_JSON_ONLY=1で出力純度確保
- cli.hako: HC012/HC013統合、デバッグ出力追加
## テスト結果
✅ HC011_dead_methods: OK
✅ HC012_dead_static_box: OK
✅ HC013_duplicate_method: OK
✅ HC016_unused_alias: OK
[TEST/SUMMARY] all green
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
{"diagnostics":[
|
||||
{"file":"ng.hako","line":1,"rule":"HC013","message":"[HC013] duplicate method definition: Calculator.add/2 at line 8","quickFix":"","severity":"warning"}
|
||||
]}
|
||||
18
tools/hako_check/tests/HC013_duplicate_method/ng.hako
Normal file
18
tools/hako_check/tests/HC013_duplicate_method/ng.hako
Normal file
@ -0,0 +1,18 @@
|
||||
// ng.hako — contains duplicate method with same name and arity
|
||||
|
||||
static box Calculator {
|
||||
method add(a, b) {
|
||||
return a + b
|
||||
}
|
||||
|
||||
method add(a, b) {
|
||||
return a + b + 1
|
||||
}
|
||||
}
|
||||
|
||||
static box Main {
|
||||
method main() {
|
||||
Calculator.add(1, 2)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
18
tools/hako_check/tests/HC013_duplicate_method/ok.hako
Normal file
18
tools/hako_check/tests/HC013_duplicate_method/ok.hako
Normal file
@ -0,0 +1,18 @@
|
||||
// ok.hako — no duplicate methods (overloading by arity is OK)
|
||||
|
||||
static box Calculator {
|
||||
method add(a, b) {
|
||||
return a + b
|
||||
}
|
||||
|
||||
method add(a, b, c) {
|
||||
return a + b + c
|
||||
}
|
||||
}
|
||||
|
||||
static box Main {
|
||||
method main() {
|
||||
Calculator.add(1, 2)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user