Skip to content

fix: crystal next compatibility #407

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
Oct 9, 2023
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
25 changes: 0 additions & 25 deletions spec/ameba/ast/variabling/assignment_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -85,30 +85,5 @@ module Ameba::AST
assignment.branch.should be_nil
end
end

describe "#transformed?" do
it "returns false if the assignment is not transformed by the compiler" do
nodes = as_nodes <<-CRYSTAL
def method(a)
a = 2
end
CRYSTAL
scope = Scope.new nodes.def_nodes.first
variable = Variable.new(nodes.var_nodes.first, scope)
assignment = Assignment.new(nodes.assign_nodes.first, variable, scope)
assignment.transformed?.should be_false
end

it "returns true if the assignment is transformed by the compiler" do
nodes = as_nodes <<-CRYSTAL
array.each do |(a, b)|
end
CRYSTAL
scope = Scope.new nodes.block_nodes.first
variable = Variable.new(nodes.var_nodes.first, scope)
assignment = Assignment.new(nodes.assign_nodes.first, variable, scope)
assignment.transformed?.should be_true
end
end
end
end
2 changes: 1 addition & 1 deletion spec/ameba/rule/lint/useless_assign_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ module Ameba::Rule::Lint
subject.catch(s).should be_valid
end

context "when transformed" do
context "block unpacking" do
it "does not report if the first arg is transformed and not used" do
s = Source.new %(
collection.each do |(a, b)|
Expand Down
3 changes: 3 additions & 0 deletions src/ameba/ast/variabling/assignment.cr
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ module Ameba::AST
end
end

# TODO: Remove in a next release. BC for crystal <= 1.9.
# refs https://github.com/crystal-ameba/ameba/pull/407
#
# Indicates whether the node is a transformed assignment by the compiler.
# i.e.
#
Expand Down