This repository was archived by the owner on May 18, 2026. It is now read-only.
fix: correctly convert variable character access to letter_of block#512
Merged
Conversation
- In variables.js, only handle '[]' if the receiver is a list block. - In operators.js, allow 'variable' type in '[]' handler to convert to 'operator_letter_of'. - This fixes a bug where $my_variable[0] was incorrectly converted to a list item block. Fixes #464 Co-Authored-By: Gemini <noreply@google.com>
github-actions Bot
pushed a commit
that referenced
this pull request
Jan 12, 2026
fix: correctly convert variable character access to letter_of block
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes issue #464 where character access on a regular variable (e.g.,
$my_variable[0]) was incorrectly converted to a list item block (data_itemoflist) instead of a character access block (operator_letter_of).Implementation details
[]handler for thevariabletype was overly broad, catching all character access. It has been modified to only return adata_itemoflistblock if the receiver is actually a list block (isListBlock). Otherwise, it returnsnullto allow other handlers to process it.[]handler (which createsoperator_letter_of) has been updated to accept thevariabletype in addition tostringandblock.Test coverage
test/unit/lib/ruby-to-blocks-converter/variables.test.jsthat verifies$variable[0]converts tooperator_letter_of.list("$var")[1]) still pass.Usage examples
Ruby code:
Now correctly converts to:
operator_letter_ofdata_variable(pointing to$my_variable)1Breaking changes
None.
Fixes #464
Co-Authored-By: Gemini noreply@google.com