From 2fb16b27e270ef2893178e0741099ee9c35c48f8 Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Tue, 10 Jan 2023 14:57:15 -0300 Subject: [PATCH 1/5] Removing Crystal::VERSION < 1.2.0 checks --- .../src/markd/renderers/html_renderer.cr | 9 ++--- spec/std/float_spec.cr | 34 ++++++++----------- spec/std/number_spec.cr | 24 ++++++------- src/indexable/mutable.cr | 6 ---- src/unicode/unicode.cr | 8 ----- 5 files changed, 27 insertions(+), 54 deletions(-) diff --git a/lib/markd/src/markd/renderers/html_renderer.cr b/lib/markd/src/markd/renderers/html_renderer.cr index 334e0d2b5c42..1b63b99cc6ff 100644 --- a/lib/markd/src/markd/renderers/html_renderer.cr +++ b/lib/markd/src/markd/renderers/html_renderer.cr @@ -235,13 +235,8 @@ module Markd private def toc(node : Node) return unless node.type.heading? - {% if Crystal::VERSION < "1.2.0" %} - title = URI.encode(node.first_child.text) - @output_io << %() - {% else %} - title = URI.encode_path(node.first_child.text) - @output_io << %() - {% end %} + title = URI.encode_path(node.first_child.text) + @output_io << %() @last_output = ">" end diff --git a/spec/std/float_spec.cr b/spec/std/float_spec.cr index b93597c389c6..a9316e888b4a 100644 --- a/spec/std/float_spec.cr +++ b/spec/std/float_spec.cr @@ -327,25 +327,21 @@ describe "Float" do (-0.0/0.0).finite?.should be_false end - {% if compare_versions(Crystal::VERSION, "0.36.1") > 0 %} - it "converts infinity" do - Float32::INFINITY.to_f64.infinite?.should eq 1 - Float32::INFINITY.to_f32.infinite?.should eq 1 - expect_raises(OverflowError) { Float32::INFINITY.to_i } - (-Float32::INFINITY).to_f64.infinite?.should eq -1 - (-Float32::INFINITY).to_f32.infinite?.should eq -1 - expect_raises(OverflowError) { (-Float32::INFINITY).to_i } - - Float64::INFINITY.to_f64.infinite?.should eq 1 - Float64::INFINITY.to_f32.infinite?.should eq 1 - expect_raises(OverflowError) { Float64::INFINITY.to_i } - (-Float64::INFINITY).to_f64.infinite?.should eq -1 - (-Float64::INFINITY).to_f32.infinite?.should eq -1 - expect_raises(OverflowError) { (-Float64::INFINITY).to_i } - end - {% else %} - pending "converts infinity" - {% end %} + it "converts infinity" do + Float32::INFINITY.to_f64.infinite?.should eq 1 + Float32::INFINITY.to_f32.infinite?.should eq 1 + expect_raises(OverflowError) { Float32::INFINITY.to_i } + (-Float32::INFINITY).to_f64.infinite?.should eq -1 + (-Float32::INFINITY).to_f32.infinite?.should eq -1 + expect_raises(OverflowError) { (-Float32::INFINITY).to_i } + + Float64::INFINITY.to_f64.infinite?.should eq 1 + Float64::INFINITY.to_f32.infinite?.should eq 1 + expect_raises(OverflowError) { Float64::INFINITY.to_i } + (-Float64::INFINITY).to_f64.infinite?.should eq -1 + (-Float64::INFINITY).to_f32.infinite?.should eq -1 + expect_raises(OverflowError) { (-Float64::INFINITY).to_i } + end it "does unary -" do f = -(1.5) diff --git a/spec/std/number_spec.cr b/spec/std/number_spec.cr index 0b703d7199d0..b517c3cc7cb8 100644 --- a/spec/std/number_spec.cr +++ b/spec/std/number_spec.cr @@ -69,20 +69,16 @@ describe "Number" do (-Float64::INFINITY).round(digits: -3).should eq -Float64::INFINITY end - {% if compare_versions(Crystal::VERSION, "0.36.1") > 0 %} - it "infinity Float32" do - Float32::INFINITY.round.should eq Float32::INFINITY - Float32::INFINITY.round(digits: 0).should eq Float32::INFINITY - Float32::INFINITY.round(digits: 3).should eq Float32::INFINITY - Float32::INFINITY.round(digits: -3).should eq Float32::INFINITY - (-Float32::INFINITY).round.should eq -Float32::INFINITY - (-Float32::INFINITY).round(digits: 0).should eq -Float32::INFINITY - (-Float32::INFINITY).round(digits: 3).should eq -Float32::INFINITY - (-Float32::INFINITY).round(digits: -3).should eq -Float32::INFINITY - end - {% else %} - pending "infinity Float32" - {% end %} + it "infinity Float32" do + Float32::INFINITY.round.should eq Float32::INFINITY + Float32::INFINITY.round(digits: 0).should eq Float32::INFINITY + Float32::INFINITY.round(digits: 3).should eq Float32::INFINITY + Float32::INFINITY.round(digits: -3).should eq Float32::INFINITY + (-Float32::INFINITY).round.should eq -Float32::INFINITY + (-Float32::INFINITY).round(digits: 0).should eq -Float32::INFINITY + (-Float32::INFINITY).round(digits: 3).should eq -Float32::INFINITY + (-Float32::INFINITY).round(digits: -3).should eq -Float32::INFINITY + end it "nan" do Float64::NAN.round.nan?.should be_true diff --git a/src/indexable/mutable.cr b/src/indexable/mutable.cr index 86331554f924..3d2fef37b192 100644 --- a/src/indexable/mutable.cr +++ b/src/indexable/mutable.cr @@ -213,7 +213,6 @@ module Indexable::Mutable(T) end end - {% begin %} # Invokes the given block for each element of `self`, replacing the element # with the value returned by the block. Returns `self`. # @@ -222,17 +221,12 @@ module Indexable::Mutable(T) # a.map! { |x| x * x } # a # => [1, 4, 9] # ``` - {% if compare_versions(Crystal::VERSION, "1.1.1") >= 0 %} def map!(& : T -> _) : self # TODO: add as constant - {% else %} - def map!(&) # it doesn't compile with the type annotation in the 1.0.0 compiler - {% end %} each_index do |i| unsafe_put(i, yield unsafe_fetch(i)) end self end - {% end %} # Like `#map!`, but the block gets passed both the element and its index. # diff --git a/src/unicode/unicode.cr b/src/unicode/unicode.cr index 6a9a7698c3d4..b6b99851df0c 100644 --- a/src/unicode/unicode.cr +++ b/src/unicode/unicode.cr @@ -134,19 +134,11 @@ module Unicode # TODO: remove the workaround for 1.0.0 eventually (needed until #10713) private macro dfa_state(*transitions) - {% if compare_versions(Crystal::VERSION, "1.1.0") >= 0 %} {% x = 0_u64 %} {% for tr, i in transitions %} {% x |= (1_u64 << (i * 6)) * tr * 6 %} {% end %} {{ x }} - {% else %} - {% x = [] of Nil %} - {% for tr, i in transitions %} - {% x << "(#{tr * 6}_u64 << #{i * 6})" %} - {% end %} - {{ x.join(" | ").id }} - {% end %} end # :nodoc: From 9e9b0518bcfaab07eaf633cd5421ecda4e0c27d0 Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Wed, 11 Jan 2023 12:05:22 -0300 Subject: [PATCH 2/5] Removing 1.0 and 1.1 from the matrix --- .github/workflows/linux.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ba107bad0e12..b7c15d41e541 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -16,12 +16,6 @@ jobs: strategy: matrix: crystal_bootstrap_version: [1.2.2, 1.3.2, 1.4.1, 1.5.1, 1.6.2] - include: - # libffi is only available starting from the 1.2.2 build images - - crystal_bootstrap_version: 1.0.0 - flags: -Dwithout_ffi - - crystal_bootstrap_version: 1.1.1 - flags: -Dwithout_ffi steps: - name: Download Crystal source uses: actions/checkout@v3 From 49748a73a8cdb85e9670460d058c6b9c001f89f5 Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Wed, 11 Jan 2023 14:39:33 -0300 Subject: [PATCH 3/5] Restored wrongly changed file from markd --- lib/markd/src/markd/renderers/html_renderer.cr | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/markd/src/markd/renderers/html_renderer.cr b/lib/markd/src/markd/renderers/html_renderer.cr index 1b63b99cc6ff..334e0d2b5c42 100644 --- a/lib/markd/src/markd/renderers/html_renderer.cr +++ b/lib/markd/src/markd/renderers/html_renderer.cr @@ -235,8 +235,13 @@ module Markd private def toc(node : Node) return unless node.type.heading? - title = URI.encode_path(node.first_child.text) - @output_io << %() + {% if Crystal::VERSION < "1.2.0" %} + title = URI.encode(node.first_child.text) + @output_io << %() + {% else %} + title = URI.encode_path(node.first_child.text) + @output_io << %() + {% end %} @last_output = ">" end From ee59796f799898456ec0b109e05680b1a7faa84f Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Wed, 11 Jan 2023 14:41:10 -0300 Subject: [PATCH 4/5] fixup --- src/unicode/unicode.cr | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/unicode/unicode.cr b/src/unicode/unicode.cr index b6b99851df0c..5f630445ea83 100644 --- a/src/unicode/unicode.cr +++ b/src/unicode/unicode.cr @@ -132,13 +132,12 @@ module Unicode array << value end - # TODO: remove the workaround for 1.0.0 eventually (needed until #10713) private macro dfa_state(*transitions) - {% x = 0_u64 %} - {% for tr, i in transitions %} - {% x |= (1_u64 << (i * 6)) * tr * 6 %} - {% end %} - {{ x }} + {% x = 0_u64 %} + {% for tr, i in transitions %} + {% x |= (1_u64 << (i * 6)) * tr * 6 %} + {% end %} + {{ x }} end # :nodoc: From a40e66097dc4a3673c42c72ac3c91bc688000c78 Mon Sep 17 00:00:00 2001 From: Beta Ziliani Date: Thu, 12 Jan 2023 14:56:50 -0300 Subject: [PATCH 5/5] Adding check --- src/compiler/crystal.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/crystal.cr b/src/compiler/crystal.cr index e6924d4d5248..884c0eed50bc 100644 --- a/src/compiler/crystal.cr +++ b/src/compiler/crystal.cr @@ -3,6 +3,11 @@ {% raise("Please use `make crystal` to build the compiler, or set the i_know_what_im_doing flag if you know what you're doing") unless env("CRYSTAL_HAS_WRAPPER") || flag?("i_know_what_im_doing") %} +{% + version = "1.2.0" + raise("Compiling Crystal requires at least version #{version.id} of Crystal. Current version is #{Crystal::VERSION}") if compare_versions(Crystal::VERSION, version.id) < 0 +%} + require "log" require "./requires"