Skip to content

Convert type keywords inside array types (#132) - #157

Merged
paulirwin merged 1 commit into
masterfrom
fix/132-array-type-keywords
Aug 14, 2026
Merged

paulirwin merged 1 commit into
masterfrom
fix/132-array-type-keywords

Conversation

@paulirwin

Copy link
Copy Markdown
Owner

Fixes #132.

Problem

Type keyword conversions (Stringstring, Integerint, etc.) were skipped whenever the type name was an array:

String[] lemmatize(String[] toks, String[] tags);

converted to String[] Lemmatize(String[] toks, String[] tags) instead of using string[].

Cause

TypeNameParser's grammar had no production for array brackets. After parsing the identifier, the [ token remained, so ParseTypeName hit its "extra tokens" fallback and returned the input verbatim — bypassing the conversion table entirely.

Fix

Added an ArraySuffix() rule and applied it after both the plain-identifier and generic branches of TypeName(), so brackets are consumed for String[], String[][], MyType<String>[], and List<String[]> alike. TypeName() was flattened to an early-return shape so both branches share the suffix handling.

Grammar is now:

TypeName     = identifier [ "<" TypeArgument { "," TypeArgument } ">" ] { "[" "]" }.
TypeArgument = [ "?" [ "extends" | "super" ] ] TypeName.

Tests

Written TDD — the new tests fail on master and pass with the fix. Added a theory covering the array shapes above plus a non-converted type (MyType[]), and an end-to-end test of the issue's exact method signature. Full suite: 273 passing.

🤖 Generated with Claude Code

TypeNameParser's grammar had no rule for array brackets, so any type name
ending in "[]" failed to parse and was returned verbatim, skipping the
String -> string style conversions.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@paulirwin
paulirwin enabled auto-merge (squash) August 14, 2026 21:18
@paulirwin
paulirwin merged commit 30b0894 into master Aug 14, 2026
5 checks passed
@paulirwin
paulirwin deleted the fix/132-array-type-keywords branch August 14, 2026 21:20
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.

Type keywords are not used for arrays

1 participant