Skip to content
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

Bump minimum required compiler to be 1.2.0 #12937

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 0 additions & 6 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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, 1.7.0]
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
Expand Down
34 changes: 15 additions & 19 deletions spec/std/float_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 10 additions & 14 deletions spec/std/number_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/compiler/crystal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 0 additions & 6 deletions src/indexable/mutable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
#
Expand All @@ -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.
#
Expand Down
17 changes: 4 additions & 13 deletions src/unicode/unicode.cr
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,12 @@ module Unicode
array << value
end

# 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 }}
{% x = 0_u64 %}
{% for tr, i in transitions %}
{% x |= (1_u64 << (i * 6)) * tr * 6 %}
{% end %}
{{ x }}
end

# :nodoc:
Expand Down