Skip to content

Improve injector validation and URL encoding in struct.lua#43

Merged
rjrodger merged 1 commit intodevfrom
claude/verify-lua-ts-implementation-kMUEQ
Feb 16, 2026
Merged

Improve injector validation and URL encoding in struct.lua#43
rjrodger merged 1 commit intodevfrom
claude/verify-lua-ts-implementation-kMUEQ

Conversation

@rjrodger
Copy link
Contributor

Summary

This PR enhances the struct.lua module with improved validation for data transformation injectors and fixes URL encoding behavior to better match standard encodeURIComponent semantics.

Key Changes

  • Injector Validation Framework: Introduced checkPlacement() and injectorArgs() helper functions to validate that transformers ($COPY, $EACH, $PACK) are used in correct modes and with proper parent types. These functions now provide consistent error reporting through the injector's error collection.

  • URL Encoding Enhancement: Updated escurl() function to preserve additional characters (! ' ( ) *) that should not be encoded according to encodeURIComponent behavior, improving compatibility with standard URL encoding.

  • Null Value Handling: Fixed join() function to properly skip null values (S_null) in addition to empty string markers (S_MT) when building string arrays.

  • Property Mutation Return Values: Modified setval() method in the Injection class to properly capture and return the parent object returned by setprop() and delprop() operations, ensuring correct parent reference tracking after mutations.

  • Argument Extraction: Refactored $EACH and $PACK transformers to use the new injectorArgs() function for type-safe argument extraction with proper error handling and reporting.

Implementation Details

  • Forward declarations added for checkPlacement and injectorArgs to support their use throughout the module
  • Error messages now consistently prefixed with injector name (e.g., '$EACH: ...')
  • Argument validation now returns error information in the first position of the result array for centralized error handling

https://claude.ai/code/session_01Jzi2moac4BhHEpNjwV2HBe

- join: filter out "null" sentinel strings to match TS null filtering
- Injection:setval: return delprop/setprop result instead of always
  self.parent, fixing transform_RENAME ancestor node detection
- escurl: match encodeURIComponent by preserving !'()* characters
- transform_COPY: use checkPlacement for proper error reporting
- transform_EACH: use checkPlacement with T_list parent type check
  and injectorArgs for argument type validation
- transform_PACK: use checkPlacement with T_map parent type check
  and injectorArgs for argument type validation
- Add forward declarations for checkPlacement and injectorArgs

https://claude.ai/code/session_01Jzi2moac4BhHEpNjwV2HBe
@rjrodger rjrodger merged commit da09074 into dev Feb 16, 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