Skip to content

Support BEGIN blocks - #486

Open
sinsoku wants to merge 1 commit into
ruby:masterfrom
sinsoku:support-begin-blocks
Open

Support BEGIN blocks#486
sinsoku wants to merge 1 commit into
ruby:masterfrom
sinsoku:support-begin-blocks

Conversation

@sinsoku

@sinsoku sinsoku commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Motivation / Background

This Pull Request has been created because a file containing a BEGIN { ... } block aborts the whole run:

BEGIN {
  x = 1
}
#=> not supported yet: pre_execution_node (RuntimeError)

The raise happens while building the AST, so one such file stops the analysis of every other file as well. ruby/ruby has one in sample/trick2025/02-mame/entry.rb. END { ... } has been supported all along.

Detail

BEGIN is installed before the surrounding statements instead of after, unlike END, so a method or a local variable it defines is visible to the statements that follow.

🤖 Generated with Claude Code

`BEGIN { ... }` raised "not supported yet: pre_execution_node" and
aborted the whole run, unlike `END { ... }`, which was already
supported. BEGIN now shares its implementation with END but is installed
before the surrounding statements instead of after, so a method or a
local variable it defines reaches the statements that follow.
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.

1 participant