Skip to content

Fix the handling of do on commands#3969

Merged
kddnewton merged 1 commit intomainfrom
fix-do
Mar 6, 2026
Merged

Fix the handling of do on commands#3969
kddnewton merged 1 commit intomainfrom
fix-do

Conversation

@kddnewton
Copy link
Collaborator

Introduce keyword_do_block to match parse.y behavior, as well as do a big audit of behavior to line up as closely as possible.

src/prism.c Outdated
if (!PM_NODE_TYPE_P(value, PM_CALL_NODE)) return false;

const pm_call_node_t *call = (const pm_call_node_t *) value;
return pm_call_node_command_p(call) && (call->receiver == NULL || call->call_operator_loc.length > 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I also tried this but I guess not. Can you put it in a different PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh whoops, yeah that was different work.

Introduce PM_TOKEN_KEYWORD_DO_BLOCK to distinguish do-blocks on
command-style calls from regular `do` keywords. Add
parse_command_do_block to attach these blocks to call nodes. Track
in_endless_def_body to prevent do-block consumption inside endless
method definitions, allowing blocks to correctly bubble up to outer
contexts like `private def f = puts "Hello" do end`.
@kddnewton kddnewton merged commit 7d17fd2 into main Mar 6, 2026
67 checks passed
@kddnewton kddnewton deleted the fix-do branch March 6, 2026 18:44
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