Skip to content

Conversation

@yhk1038
Copy link
Contributor

@yhk1038 yhk1038 commented Jan 10, 2026

Summary

  • TypeScript 스타일의 배열 축약 문법 String[]을 추가합니다
  • 기존 Array<String> 문법과 완전히 동일한 IR 및 RBS 출력을 생성합니다
  • 중첩 배열 (Integer[][]), nullable 배열 (String[]?), nullable 요소 배열 (String?[]) 모두 지원

Changes

  • parse_postfix_type_operators 메서드 추가로 []? 후위 연산자 처리
  • TokenDeclarationParserTypeParser에 배열 축약 문법 지원
  • 단위 테스트 15개, E2E 테스트 14개 추가
  • README 예시 업데이트 (영어/한국어/일본어)

Examples

# Before (still works)
items: Array<String>

# After (new syntax)
items: String[]

# Nested arrays
matrix: Integer[][]

# Nullable array
cache: String[]?

# Array of nullable elements  
optional: String?[]

Test plan

  • bundle exec rspec spec/t_ruby/token_declaration_parser_spec.rb - 32 examples pass
  • bundle exec rspec spec/e2e/array_shorthand_spec.rb - 14 examples pass (2 pending)
  • bundle exec rspec - 3270 examples, 0 failures

- Add `String[]` as alternative to `Array<String>`
- Support nested arrays: `Integer[][]` → `Array[Array[Integer]]`
- Support nullable arrays: `String[]?` → `(Array[String] | nil)`
- Support arrays of nullable elements: `String?[]` → `Array[String?]`
- Support union type arrays: `(String | Integer)[]`
- Both syntaxes produce identical IR and RBS output
- Add parse_postfix_type_operators for `[]` and `?` suffix handling
- Add comprehensive unit tests (15 cases) and E2E tests (14 cases)
- Update README examples to show new syntax
@yhk1038 yhk1038 closed this Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants