Thanks to visit codestin.com
Credit goes to github.com

Skip to content

opt_new needs to happen after safe navigation #13205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions prism_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3621,8 +3621,6 @@ pm_compile_call(rb_iseq_t *iseq, const pm_call_node_t *call_node, LINK_ANCHOR *c

const pm_node_location_t location = PM_LOCATION_START_LOCATION(scope_node->parser, message_loc, call_node->base.node_id);

LINK_ELEMENT *opt_new_prelude = LAST_ELEMENT(ret);

LABEL *else_label = NEW_LABEL(location.line);
LABEL *end_label = NEW_LABEL(location.line);
LABEL *retry_end_l = NEW_LABEL(location.line);
Expand Down Expand Up @@ -3661,6 +3659,8 @@ pm_compile_call(rb_iseq_t *iseq, const pm_call_node_t *call_node, LINK_ANCHOR *c
add_trace_branch_coverage(iseq, ret, &code_location, node_id, 0, "then", branches);
}

LINK_ELEMENT *opt_new_prelude = LAST_ELEMENT(ret);

int flags = 0;
struct rb_callinfo_kwarg *kw_arg = NULL;

Expand Down
5 changes: 5 additions & 0 deletions test/ruby/test_optimization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,11 @@ def == x
RUBY
end

def test_opt_new_with_safe_navigation
payload = nil
assert_nil payload&.new
end

def test_opt_new
pos_initialize = "
def initialize a, b
Expand Down
Loading