From ac8f575a510407f6dfedcffcca5cf9e782ef0136 Mon Sep 17 00:00:00 2001 From: Andrii Konchyn Date: Thu, 29 Oct 2026 21:19:44 +0200 Subject: [PATCH] Fix issue with quarantined specs for #syntax_tree --- core/proc/fixtures/syntax_tree.rb | 14 ++++++++++++++ core/proc/syntax_tree_spec.rb | 12 ++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 core/proc/fixtures/syntax_tree.rb diff --git a/core/proc/fixtures/syntax_tree.rb b/core/proc/fixtures/syntax_tree.rb new file mode 100644 index 000000000..88f145c2f --- /dev/null +++ b/core/proc/fixtures/syntax_tree.rb @@ -0,0 +1,14 @@ +# Avoids warnings on Ruby 3.3 +module ProcSpecs + module SyntaxTree + def self.lambda_it + -> { it } + end + LAMBDA_IT_LINE = __LINE__ - 2 + + def self.proc_it + proc { it } + end + PROC_IT_LINE = __LINE__ - 2 + end +end diff --git a/core/proc/syntax_tree_spec.rb b/core/proc/syntax_tree_spec.rb index ec25271ff..b772f1640 100644 --- a/core/proc/syntax_tree_spec.rb +++ b/core/proc/syntax_tree_spec.rb @@ -2,6 +2,8 @@ require_relative '../../fixtures/source_range_helpers' ruby_version_is "4.1" do + require_relative 'fixtures/syntax_tree' # avoids warnings on Ruby 3.3 + describe "Proc#syntax_tree" do before :each do skip "parse.y" unless syntax_tree_returns_prism_node @@ -38,26 +40,24 @@ def return_block(&b) node.should.is_a?(Ruby::Prism::LambdaNode) end - quarantine! do # NoMethodError: undefined method 'start_line' for nil it "does not return implicit parameter nodes" do # Interesting because the BlockNode and the ItParametersNode/NumberedParametersNode are fully overlapping - node = eval('-> { it }.syntax_tree') # emits a warning on Ruby 3.3 - node.start_line.should == __LINE__ - 1 + node = ProcSpecs::SyntaxTree.lambda_it.syntax_tree + node.start_line.should == ProcSpecs::SyntaxTree::LAMBDA_IT_LINE node.should.is_a?(Ruby::Prism::LambdaNode) node = -> { _1 }.syntax_tree node.start_line.should == __LINE__ - 1 node.should.is_a?(Ruby::Prism::LambdaNode) - node = eval('proc { it }.syntax_tree') # emits a warning on Ruby 3.3 - node.start_line.should == __LINE__ - 1 + node = ProcSpecs::SyntaxTree.proc_it.syntax_tree + node.start_line.should == ProcSpecs::SyntaxTree::PROC_IT_LINE node.should.is_a?(Ruby::Prism::CallNode) node = proc { _1 }.syntax_tree node.start_line.should == __LINE__ - 1 node.should.is_a?(Ruby::Prism::CallNode) end - end it "returns a ForNode for a for-loop block" do iter = Object.new