Skip to content

refactor: unify Diagnostic type + reserved word validation#196

Merged
ohah merged 6 commits intomainfrom
feature/diagnostic-unification
Mar 20, 2026
Merged

refactor: unify Diagnostic type + reserved word validation#196
ohah merged 6 commits intomainfrom
feature/diagnostic-unification

Conversation

@ohah
Copy link
Copy Markdown
Owner

@ohah ohah commented Mar 20, 2026

Summary

  • ParseErrorSemanticError를 공통 Diagnostic 타입으로 통합 (src/diagnostic.zig)
  • CLI에서 semantic 에러도 코드 프레임으로 표시 (error[semantic]: 라벨)
  • Escaped keyword 검증 강화 + 이중 에러 방지
  • JSX 코드젠 버그 수정: transformer가 jsx_element를 .list로 읽던 문제 → .extra 전용 visit 함수 + 항상 5-field encoding
  • 에러 메시지 일관성: ~70개 에러 메시지 대문자 통일 (oxc/TypeScript 스타일)
  • config.zig 중복 코드 정리: 7번 반복되던 문자열 옵션 패턴 → dupeJsonString/mergeOptionalString 헬퍼
  • Semantic 테스트 보강: Diagnostic kind, 메시지 내용, 중복 export, valid code 검증 4개 추가
  • Legal comments: single-line // @license/// @preserve 감지 추가 + isLegalComment 헬퍼 추출
  • Silent catch 수정: sourcemap 초기화 실패 시 에러 메시지 출력
  • rest parameter 중복 제거: 5곳 동일 패턴 → checkRestParameterLast() 헬퍼
  • checkYieldAwaitUse: voidbool 반환으로 err_count 트릭 제거
  • CLAUDE.md 업데이트: Test262 100%, Phase 2 에러복구/semantic ✅, legal comments ✅, @Panic 정리 계획 문서화

Test plan

  • zig build test 전체 통과
  • zig build test262 전체 통과 (100% 유지)
  • JSX E2E 테스트 3개 활성화 및 통과
  • Legal comment 테스트 5개 추가 및 통과
  • Semantic 유닛 테스트 4개 추가 및 통과
  • 예약어 검증 테스트 7개 추가 및 통과
  • /simplify 리뷰 2회 완료

🤖 Generated with Claude Code

…ord validation

- Create src/diagnostic.zig with unified Diagnostic type (span, message, found, related_span, related_label, hint, kind)
- Replace ParseError in parser with Diagnostic (kind=.parse)
- Replace SemanticError in semantic analyzer/checker with Diagnostic (kind=.semantic)
- Add semantic error display in CLI with code frames (error[semantic] label)
- Strengthen escaped keyword validation: checkStrictBinding handles escaped eval/arguments, checkIdentifierEscapedKeyword validates strict reserved in strict mode, checkKeywordBinding handles escaped_keyword/escaped_strict_reserved tokens
- Add unit tests for Diagnostic kind and reserved word edge cases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ohah ohah added the enhancement New feature or request label Mar 20, 2026
@ohah ohah self-assigned this Mar 20, 2026
@ohah ohah added the enhancement New feature or request label Mar 20, 2026
ohah and others added 5 commits March 21, 2026 00:43
- Remove duplicate doc comment on errors field
- Merge identical error branches in checkIdentifierEscapedKeyword
- Prevent double error in checkKeywordBinding escaped_strict_reserved branch
- Pass is_strict_mode/is_module to SemanticAnalyzer in CLI
- Stop transformation when parser or semantic errors exist

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…antic tests

- Fix transformer jsx_element/jsx_opening_element routing: .extra format, not .list
  - Add visitJSXElement (handles self-closing 3-field and with-children 5-field)
  - Add visitJSXOpeningElement
  - Enable 3 previously disabled JSX codegen E2E tests
- Capitalize all parser error messages consistently (oxc/TypeScript style)
  - ~70 messages across 8 parser files standardized to sentence case
- Extract dupeJsonString/mergeOptionalString helpers in config.zig
  - 7 repeated string option patterns → helper function calls
  - Fix extends inheritance bug (JSON keys override merged base values)
- Add 4 semantic analyzer unit tests (Diagnostic kind, message content, valid code)
- Update CLAUDE.md: Test262 100%, Phase 2 items ✅

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Detect @license/@preserve in single-line comments (was only multi-line)
- Add 5 legal comment unit tests (multi-line @license//*!, single-line @license/@preserve, normal)
- Replace silent catch {} on sourcemap init with error message output
- Document @Panic("OOM") cleanup plan in CLAUDE.md (44 instances, resolve with Arena)
- Mark legal comments ✅ in CLAUDE.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- JSX parser: always store 5 extra fields (children_len=0 for self-closing)
  - Eliminates fragile heuristic in transformer and codegen
  - Codegen reads children_start/children_len directly
- Extract isLegalComment() helper in scanner (removes duplication)
- visitJSXOpeningElement delegates to shared visitJSXExtraNode helper
- checkYieldAwaitUse returns bool instead of void (removes err_count trick)
- Fix 'Import.meta' error messages to use lowercase 'import.meta'

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract checkRestParameterLast() in parser — replaces 5 identical
  spread_element + comma check patterns across declaration.zig/object.zig
- Fix "Delete of an identifier" → "Deleting an identifier" (natural English)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ohah ohah merged commit 3cab22e into main Mar 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant