Skip to content

Fix codegen for directly returning new primitive arrays#208

Open
binawoh-sudo wants to merge 1 commit into
Syncleus:masterfrom
binawoh-sudo:fix-return-new-array-codegen
Open

Fix codegen for directly returning new primitive arrays#208
binawoh-sudo wants to merge 1 commit into
Syncleus:masterfrom
binawoh-sudo:fix-return-new-array-codegen

Conversation

@binawoh-sudo
Copy link
Copy Markdown

@binawoh-sudo binawoh-sudo commented May 14, 2026

Fixes #66.

This allows codegen for direct primitive array returns such as:

return new double[1024];

The writer now emits a local primitive array declaration before returning it, matching the existing supported workaround where the array is assigned to a local variable first.

Updated the Return*ArrayNew codegen tests for all primitive array types.

Tested:

  • git diff --check
  • Verified local Java/Maven availability: Java 17.0.19 and Maven 3.9.11

Not tested:

  • Maven target tests were attempted locally, but the build failed before running the project tests due to a scala-maven-plugin/Jansi NoSuchMethodError in this local toolchain.

The code generator already handled primitive arrays returned through a local variable, but rejected the equivalent direct return form from issue Syncleus#66. This emits a local array declaration before returning it so direct new-array returns follow the same generated OpenCL shape as the existing workaround.

Constraint: Existing codegen tests compare exact OpenCL strings.
Rejected: Only remove the explicit exception guard | the writer still needed a local array name to return.
Confidence: medium
Scope-risk: narrow
Tested: git diff --check
Not-tested: Maven target tests attempted but blocked before project tests by scala-maven-plugin/Jansi NoSuchMethodError in the local toolchain.
@binawoh-sudo binawoh-sudo force-pushed the fix-return-new-array-codegen branch from 4bd16aa to 21b63e8 Compare May 14, 2026 03:43
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.

[BOUNTY $25] Can not directly return an instantiated array.

1 participant