rdl 2.0.0.rc2 → 2.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +7 -1
- data/README.md +94 -20
- data/lib/rdl.rb +4 -1
- data/lib/rdl/config.rb +90 -3
- data/lib/rdl/info.rb +16 -0
- data/lib/rdl/typecheck.rb +207 -79
- data/lib/rdl/types/bot.rb +1 -1
- data/lib/rdl/types/dependent_arg.rb +17 -8
- data/lib/rdl/types/{finitehash.rb → finite_hash.rb} +3 -29
- data/lib/rdl/types/generic.rb +1 -37
- data/lib/rdl/types/intersection.rb +1 -0
- data/lib/rdl/types/lexer.rex +2 -1
- data/lib/rdl/types/lexer.rex.rb +4 -1
- data/lib/rdl/types/method.rb +2 -12
- data/lib/rdl/types/nominal.rb +1 -22
- data/lib/rdl/types/non_null.rb +50 -0
- data/lib/rdl/types/parser.racc +3 -1
- data/lib/rdl/types/parser.tab.rb +222 -190
- data/lib/rdl/types/singleton.rb +1 -6
- data/lib/rdl/types/structural.rb +1 -10
- data/lib/rdl/types/top.rb +1 -2
- data/lib/rdl/types/tuple.rb +3 -19
- data/lib/rdl/types/type.rb +223 -0
- data/lib/rdl/types/union.rb +12 -2
- data/lib/rdl/types/var.rb +4 -1
- data/lib/rdl/types/wild_query.rb +1 -0
- data/lib/rdl/wrap.rb +199 -169
- data/lib/rdl_disable.rb +41 -0
- data/lib/rdl_types.rb +1 -4
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/_aliases.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/abbrev.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/array.rb +56 -56
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/base64.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/basic_object.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/benchmark.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/bigdecimal.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/bigmath.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/bignum.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/class.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/complex.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/coverage.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/csv.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/date.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/dir.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/encoding.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/enumerable.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/enumerator.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/exception.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/file.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/fileutils.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/fixnum.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/float.rb +26 -26
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/gem.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/hash.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/integer.rb +8 -8
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/io.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/kernel.rb +12 -11
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/marshal.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/matchdata.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/math.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/module.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/nil.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/numeric.rb +0 -0
- data/lib/types/core-ruby-2.x/object.rb +75 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/pathname.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/process.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/random.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/range.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/rational.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/regexp.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/set.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/string.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/strscan.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/symbol.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/time.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/uri.rb +0 -0
- data/{types/ruby-2.x → lib/types/core-ruby-2.x}/yaml.rb +0 -0
- data/lib/types/core.rb +4 -0
- data/rdl.gemspec +2 -2
- data/test/test_le.rb +77 -35
- data/test/test_parser.rb +75 -59
- data/test/test_rdl.rb +18 -0
- data/test/test_typecheck.rb +73 -4
- metadata +54 -57
- data/lib/rails_types.rb +0 -1
- data/types/rails-4.2.1/fixnum.rb +0 -3
- data/types/rails-4.2.1/string.rb +0 -3
- data/types/rails-tmp/action_dispatch.rb +0 -406
- data/types/rails-tmp/active_record.rb +0 -406
- data/types/rails-tmp/devise_contracts.rb +0 -216
- data/types/ruby-2.x/object.rb +0 -73
data/lib/rdl_disable.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Defines RDL methods that do nothing
|
2
|
+
|
3
|
+
module RDL; end
|
4
|
+
|
5
|
+
def RDL.config(*args); end
|
6
|
+
|
7
|
+
class Object
|
8
|
+
def pre(*args); end
|
9
|
+
def post(*args); end
|
10
|
+
def type(*args); end
|
11
|
+
def var_type(*args); end
|
12
|
+
def rdl_alias(*args); end
|
13
|
+
def type_params(*args); end
|
14
|
+
def rdl_nowrap(*args); end
|
15
|
+
def instantaite!(*args); self; end
|
16
|
+
def deinstantaite!(*args); self; end
|
17
|
+
def type_cast(*args); self; end
|
18
|
+
def type_alias(*args); end
|
19
|
+
def rdl_do_typecheck(*args); end
|
20
|
+
def rdl_note_type(*args); end
|
21
|
+
|
22
|
+
def attr_accessor_type(*args)
|
23
|
+
args.each_slice(2) { |name, typ| attr_accessor name }
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def attr_reader_type(*args)
|
28
|
+
args.each_slice(2) { |name, typ| attr_reader name }
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
alias_method :attr_type, :attr_reader_type
|
33
|
+
|
34
|
+
def attr_writer_type(*args)
|
35
|
+
args.each_slice(2) { |name, typ| attr_writer name }
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
end
|
data/lib/rdl_types.rb
CHANGED
File without changes
|
File without changes
|
@@ -4,82 +4,82 @@ class Array
|
|
4
4
|
type_params [:t], :all?
|
5
5
|
|
6
6
|
type :<<, '(t) -> Array<t>'
|
7
|
-
type :[], '(Range
|
8
|
-
type :[], '(
|
9
|
-
type :[], '(
|
7
|
+
type :[], '(Range<%integer>) -> Array<t>'
|
8
|
+
type :[], '(%integer or Float) -> t'
|
9
|
+
type :[], '(%integer, %integer) -> Array<t>'
|
10
10
|
type :&, '(Array<u>) -> Array<t>'
|
11
|
-
type :*, '(
|
11
|
+
type :*, '(%integer) -> Array<t>'
|
12
12
|
type :*, '(String) -> String'
|
13
13
|
type :+, '(Enumerable<u>) -> Array<u or t>'
|
14
14
|
type :-, '(Array<u>) -> Array<u or t>'
|
15
|
-
type :slice, '(Range
|
16
|
-
type :slice, '(
|
17
|
-
type :slice, '(
|
18
|
-
type :[]=, '(
|
19
|
-
type :[]=, '(
|
20
|
-
#type :[]=, '(
|
15
|
+
type :slice, '(Range<%integer>) -> Array<t>'
|
16
|
+
type :slice, '(%integer) -> t'
|
17
|
+
type :slice, '(%integer, %integer) -> Array<t>'
|
18
|
+
type :[]=, '(%integer, t) -> t'
|
19
|
+
type :[]=, '(%integer, %integer, t) -> t'
|
20
|
+
#type :[]=, '(%integer, %integer, Array<t>) -> Array<t>'
|
21
21
|
#type :[]=, '(Range, Array<t>) -> Array<t>'
|
22
|
-
type :[]=, '(Range
|
22
|
+
type :[]=, '(Range<%integer>, t) -> t'
|
23
23
|
type :assoc, '(t) -> Array<t>'
|
24
|
-
type :at, '(
|
24
|
+
type :at, '(%integer) -> t'
|
25
25
|
type :clear, '() -> Array<t>'
|
26
|
-
type :map, '() {(t) ->u} -> Array<u>'
|
26
|
+
type :map, '() {(t) -> u} -> Array<u>'
|
27
27
|
type :map, '() -> Enumerator<t>'
|
28
|
-
type :map!, '() {(t) ->u} -> Array<u>'
|
28
|
+
type :map!, '() {(t) -> u} -> Array<u>'
|
29
29
|
type :map!, '() -> Enumerator<t>'
|
30
30
|
type :collect, '() { (t) -> u } -> Array<u>'
|
31
31
|
type :collect, '() -> Enumerator<t>'
|
32
|
-
type :combination, '(
|
33
|
-
type :combination, '(
|
32
|
+
type :combination, '(%integer) { (Array<t>) -> %any } -> Array<t>'
|
33
|
+
type :combination, '(%integer) -> Enumerator<t>'
|
34
34
|
type :push, '(?t) -> Array<t>'
|
35
35
|
type :compact, '() -> Array<t>'
|
36
36
|
type :compact!, '() -> Array<t>'
|
37
37
|
type :concat, '(Array<t>) -> Array<t>'
|
38
|
-
type :count, '() ->
|
39
|
-
type :count, '(t) ->
|
40
|
-
type :count, '() { (t) -> %bool } ->
|
41
|
-
type :cycle, '(
|
42
|
-
type :cycle, '(
|
38
|
+
type :count, '() -> %integer'
|
39
|
+
type :count, '(t) -> %integer'
|
40
|
+
type :count, '() { (t) -> %bool } -> %integer'
|
41
|
+
type :cycle, '(?%integer) { (t) -> %any } -> %any'
|
42
|
+
type :cycle, '(?%integer) -> Enumerator<t>'
|
43
43
|
type :delete, '(u) -> t'
|
44
44
|
type :delete, '(u) { () -> v } -> t or v'
|
45
|
-
type :delete_at, '(
|
45
|
+
type :delete_at, '(%integer) -> Array<t>'
|
46
46
|
type :delete_if, '() { (t) -> %bool } -> Array<t>'
|
47
47
|
type :delete_if, '() -> Enumerator<t>'
|
48
|
-
type :drop, '(
|
48
|
+
type :drop, '(%integer) -> Array<t>'
|
49
49
|
type :drop_while, '() { (t) -> %bool } -> Array<t>'
|
50
50
|
type :drop_while, '() -> Enumerator<t>'
|
51
51
|
type :each, '() -> Enumerator<t>'
|
52
52
|
type :each, '() { (t) -> %any } -> Array<t>'
|
53
|
-
type :each_index, '() { (
|
53
|
+
type :each_index, '() { (%integer) -> %any } -> Array<t>'
|
54
54
|
type :each_index, '() -> Enumerator<t>'
|
55
55
|
type :empty?, '() -> %bool'
|
56
|
-
type :fetch, '(
|
57
|
-
type :fetch, '(
|
58
|
-
type :fetch, '(
|
56
|
+
type :fetch, '(%integer) -> t'
|
57
|
+
type :fetch, '(%integer, u) -> u'
|
58
|
+
type :fetch, '(%integer) { (%integer) -> u } -> t or u'
|
59
59
|
type :fill, '(t) -> Array<t>'
|
60
|
-
type :fill, '(t,
|
61
|
-
type :fill, '(t, Range
|
62
|
-
type :fill, '() { (
|
63
|
-
type :fill, '(
|
64
|
-
type :fill, '(Range
|
60
|
+
type :fill, '(t, %integer, ?%integer) -> Array<t>'
|
61
|
+
type :fill, '(t, Range<%integer>) -> Array<t>'
|
62
|
+
type :fill, '() { (%integer) -> t } -> Array<t>'
|
63
|
+
type :fill, '(%integer, ?%integer) { (%integer) -> t } -> Array<t>'
|
64
|
+
type :fill, '(Range<%integer>) { (%integer) -> t } -> Array<t>'
|
65
65
|
type :flatten, '() -> Array<%any>' # Can't give a more precise type
|
66
|
-
type :index, '(u) ->
|
67
|
-
type :index, '() { (t) -> %bool } ->
|
66
|
+
type :index, '(u) -> %integer'
|
67
|
+
type :index, '() { (t) -> %bool } -> %integer'
|
68
68
|
type :index, '() -> Enumerator<t>'
|
69
69
|
type :first, '() -> t'
|
70
|
-
type :first, '(
|
70
|
+
type :first, '(%integer) -> Array<t>'
|
71
71
|
type :include?, '(u) -> %bool'
|
72
|
-
type :insert, '(
|
72
|
+
type :insert, '(%integer, *t) -> Array<t>'
|
73
73
|
type :inspect, '() -> String'
|
74
74
|
type :join, '(?String) -> String'
|
75
75
|
type :keep_if, '() { (t) -> %bool } -> Array<t>'
|
76
76
|
type :last, '() -> t'
|
77
|
-
type :last, '(
|
77
|
+
type :last, '(%integer) -> Array<t>'
|
78
78
|
type :member, '(u) -> %bool'
|
79
79
|
type :length, '() -> Fixnum'
|
80
|
-
type :permutation, '(
|
81
|
-
type :permutation, '(
|
82
|
-
type :pop, '(
|
80
|
+
type :permutation, '(?%integer) -> Enumerator<t>'
|
81
|
+
type :permutation, '(?%integer) { (Array<t>) -> %any } -> Array<t>'
|
82
|
+
type :pop, '(%integer) -> Array<t>'
|
83
83
|
type :pop, '() -> t'
|
84
84
|
type :product, '(*Array<u>) -> Array<Array<t or u>>'
|
85
85
|
type :rassoc, '(u) -> t'
|
@@ -87,41 +87,41 @@ class Array
|
|
87
87
|
type :reject, '() -> Enumerator<t>'
|
88
88
|
type :reject!, '() { (t) -> %bool } -> Array<t>'
|
89
89
|
type :reject!, '() -> Enumerator<t>'
|
90
|
-
type :repeated_combination, '(
|
91
|
-
type :repeated_combination, '(
|
92
|
-
type :repeated_permutation, '(
|
93
|
-
type :repeated_permutation, '(
|
90
|
+
type :repeated_combination, '(%integer) { (Array<t>) -> %any } -> Array<t>'
|
91
|
+
type :repeated_combination, '(%integer) -> Enumerator<t>'
|
92
|
+
type :repeated_permutation, '(%integer) { (Array<t>) -> %any } -> Array<t>'
|
93
|
+
type :repeated_permutation, '(%integer) -> Enumerator<t>'
|
94
94
|
type :reverse, '() -> Array<t>'
|
95
95
|
type :reverse!, '() -> Array<t>'
|
96
96
|
type :reverse_each, '() { (t) -> %any } -> Array<t>'
|
97
97
|
type :reverse_each, '() -> Enumerator<t>'
|
98
98
|
type :rindex, '(u) -> t'
|
99
|
-
type :rindex, '() { (t) -> %bool } ->
|
99
|
+
type :rindex, '() { (t) -> %bool } -> %integer'
|
100
100
|
type :rindex, '() -> Enumerator<t>'
|
101
|
-
type :rotate, '(
|
102
|
-
type :rotate!, '(
|
101
|
+
type :rotate, '(?%integer) -> Array<t>'
|
102
|
+
type :rotate!, '(?%integer) -> Array<t>'
|
103
103
|
type :sample, '() -> t'
|
104
|
-
type :sample, '(
|
104
|
+
type :sample, '(%integer) -> Array<t>'
|
105
105
|
type :select, '() { (t) -> %bool } -> Array<t>'
|
106
106
|
type :select, '() -> Enumerator<t>'
|
107
107
|
type :select!, '() { (t) -> %bool } -> Array<t>'
|
108
108
|
type :select!, '() -> Enumerator<t>'
|
109
109
|
type :shift, '() -> t'
|
110
|
-
type :shift, '(
|
110
|
+
type :shift, '(%integer) -> Array<t>'
|
111
111
|
type :shuffle, '() -> Array<t>'
|
112
112
|
type :shuffle!, '() -> Array<t>'
|
113
113
|
rdl_alias :size, :length
|
114
114
|
rdl_alias :slice, :[]
|
115
|
-
type :slice!, '(Range
|
116
|
-
type :slice!, '(
|
117
|
-
type :slice!, '(
|
115
|
+
type :slice!, '(Range<%integer>) -> Array<t>'
|
116
|
+
type :slice!, '(%integer, %integer) -> Array<t>'
|
117
|
+
type :slice!, '(%integer or Float) -> t'
|
118
118
|
type :sort, '() -> Array<t>'
|
119
|
-
type :sort, '() { (t,t) ->
|
119
|
+
type :sort, '() { (t,t) -> %integer } -> Array<t>'
|
120
120
|
type :sort!, '() -> Array<t>'
|
121
|
-
type :sort!, '() { (t,t) ->
|
121
|
+
type :sort!, '() { (t,t) -> %integer } -> Array<t>'
|
122
122
|
type :sort_by!, '() { (t) -> u } -> Array<t>'
|
123
123
|
type :sort_by!, '() -> Enumerator<t>'
|
124
|
-
type :take, '(
|
124
|
+
type :take, '(%integer) -> Array<t>'
|
125
125
|
type :take_while, '() { (t) ->%bool } -> Array<t>'
|
126
126
|
type :take_while, '() -> Enumerator<t>'
|
127
127
|
type :to_a, '() -> Array<t>'
|
@@ -131,7 +131,7 @@ class Array
|
|
131
131
|
type :uniq, '() -> Array<t>'
|
132
132
|
type :uniq!, '() -> Array<t>'
|
133
133
|
type :unshift, '(*t) -> Array<t>'
|
134
|
-
type :values_at, '(*Range
|
134
|
+
type :values_at, '(*Range<%integer> or %integer) -> Array<t>'
|
135
135
|
type :zip, '(*Array<u>) -> Array<Array<t or u>>'
|
136
136
|
type :|, '(Array<u>) -> Array<t or u>'
|
137
137
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class Float < Numeric
|
2
2
|
rdl_nowrap
|
3
3
|
|
4
|
-
type :%, '(%integer x {{ x!=0 }}) -> Float'
|
5
|
-
type :%, '(Float x {{ x!=0 }}) -> Float'
|
6
|
-
type :%, '(Rational x {{ x!=0 }}) -> Float'
|
7
|
-
type :%, '(BigDecimal x {{ x!=0 && !self.infinite? && !self.nan? }}) -> BigDecimal'
|
4
|
+
type :%, '(%integer x {{ x != 0 }}) -> Float'
|
5
|
+
type :%, '(Float x {{ x != 0 }}) -> Float'
|
6
|
+
type :%, '(Rational x {{ x != 0 }}) -> Float'
|
7
|
+
type :%, '(BigDecimal x {{ x != 0 && !self.infinite? && !self.nan? }}) -> BigDecimal'
|
8
8
|
|
9
9
|
type :*, '(%integer) -> Float'
|
10
10
|
type :*, '(Float) -> Float'
|
@@ -20,7 +20,7 @@ class Float < Numeric
|
|
20
20
|
pre(:**) { |x| x!=BigDecimal::INFINITY && if self<0 then x<=-1||x>=0 else true end}
|
21
21
|
post(:**) { |x| x.real?}
|
22
22
|
type :**, '(Complex) -> Complex'
|
23
|
-
pre(:**) { |x| x!=0 && if (x.real.is_a?(BigDecimal)||x.imaginary.is_a?(BigDecimal)) then (if x.real.is_a?(Float) then (x.real!=Float::INFINITY && !(x.real.nan?)) elsif(x.imaginary.is_a?(Float)) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end) && self!=Float::INFINITY && !(self.nan?) else true end}
|
23
|
+
pre(:**) { |x| x != 0 && if (x.real.is_a?(BigDecimal)||x.imaginary.is_a?(BigDecimal)) then (if x.real.is_a?(Float) then (x.real!=Float::INFINITY && !(x.real.nan?)) elsif(x.imaginary.is_a?(Float)) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end) && self!=Float::INFINITY && !(self.nan?) else true end}
|
24
24
|
|
25
25
|
type :+, '(%integer) -> Float'
|
26
26
|
type :+, '(Float) -> Float'
|
@@ -38,11 +38,11 @@ class Float < Numeric
|
|
38
38
|
|
39
39
|
type :-, '() -> Float'
|
40
40
|
|
41
|
-
type :/, '(%integer x {{ x!=0 }}) -> Float'
|
42
|
-
type :/, '(Float x {{ x!=0 }}) -> Float'
|
43
|
-
type :/, '(Rational x {{ x!=0 }}) -> Float'
|
44
|
-
type :/, '(BigDecimal x {{ x!=0 && !self.infinite? && !self.nan? }}) -> BigDecimal'
|
45
|
-
type :/, '(Complex x {{ x!=0 }}) -> Complex'
|
41
|
+
type :/, '(%integer x {{ x != 0 }}) -> Float'
|
42
|
+
type :/, '(Float x {{ x != 0 }}) -> Float'
|
43
|
+
type :/, '(Rational x {{ x != 0 }}) -> Float'
|
44
|
+
type :/, '(BigDecimal x {{ x != 0 && !self.infinite? && !self.nan? }}) -> BigDecimal'
|
45
|
+
type :/, '(Complex x {{ x != 0 }}) -> Complex'
|
46
46
|
pre(:/) { |x| if (x.real.is_a?(BigDecimal)||x.imaginary.is_a?(BigDecimal)) then (if x.real.is_a?(Float) then (x.real!=Float::INFINITY && !(x.real.nan?)) elsif(x.imaginary.is_a?(Float)) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end) && self!=Float::INFINITY && !(self.nan?) else true end && if (x.real.is_a?(Rational) && x.imaginary.is_a?(Float)) then !x.imaginary.nan? else true end}
|
47
47
|
|
48
48
|
type :<, '(%integer) -> %bool'
|
@@ -84,13 +84,13 @@ class Float < Numeric
|
|
84
84
|
|
85
85
|
type :abs2, '() -> Float r {{ r>=0 }}'
|
86
86
|
|
87
|
-
type :div, '(%integer x {{ x!=0 && !self.infinite? && !self.nan? }}) -> %integer'
|
88
|
-
type :div, '(Float x {{ x!=0 && !self.infinite? && !self.nan? }}) -> %integer'
|
89
|
-
type :div, '(Rational x {{ x!=0 && !self.infinite? && !self.nan? }}) -> %integer'
|
90
|
-
type :div, '(BigDecimal x {{ x!=0 && !x.nan? && !self.infinite? && !self.nan? }}) -> %integer'
|
87
|
+
type :div, '(%integer x {{ x != 0 && !self.infinite? && !self.nan? }}) -> %integer'
|
88
|
+
type :div, '(Float x {{ x != 0 && !self.infinite? && !self.nan? }}) -> %integer'
|
89
|
+
type :div, '(Rational x {{ x != 0 && !self.infinite? && !self.nan? }}) -> %integer'
|
90
|
+
type :div, '(BigDecimal x {{ x != 0 && !x.nan? && !self.infinite? && !self.nan? }}) -> %integer'
|
91
91
|
|
92
92
|
type :divmod, '(%real) -> [%real, %real]'
|
93
|
-
pre(:divmod) { |x| x!=0 && if x.is_a?(Float) then !x.nan? else true end && self!=Float::INFINITY && !self.nan?}
|
93
|
+
pre(:divmod) { |x| x != 0 && if x.is_a?(Float) then !x.nan? else true end && self!=Float::INFINITY && !self.nan?}
|
94
94
|
|
95
95
|
type :angle, '() -> %numeric'
|
96
96
|
post(:angle) { |r,x| r == 0 || r == Math::PI || r == Float::NAN}
|
@@ -114,7 +114,7 @@ class Float < Numeric
|
|
114
114
|
type :fdiv, '(Rational) -> Float'
|
115
115
|
type :fdiv, '(BigDecimal x {{ !self.infinite? && !self.nan? }}) -> BigDecimal'
|
116
116
|
type :fdiv, '(Complex) -> Complex'
|
117
|
-
pre(:fdiv) { |x| x!=0 && if (x.real.is_a?(BigDecimal)||x.imaginary.is_a?(BigDecimal)) then (if x.real.is_a?(Float) then (x.real!=Float::INFINITY && !(x.real.nan?)) elsif(x.imaginary.is_a?(Float)) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end) && self!=Float::INFINITY && !(self.nan?) else true end && if (x.real.is_a?(Rational) && x.imaginary.is_a?(Float)) then !x.imaginary.nan? else true end}
|
117
|
+
pre(:fdiv) { |x| x != 0 && if (x.real.is_a?(BigDecimal)||x.imaginary.is_a?(BigDecimal)) then (if x.real.is_a?(Float) then (x.real!=Float::INFINITY && !(x.real.nan?)) elsif(x.imaginary.is_a?(Float)) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end) && self!=Float::INFINITY && !(self.nan?) else true end && if (x.real.is_a?(Rational) && x.imaginary.is_a?(Float)) then !x.imaginary.nan? else true end}
|
118
118
|
|
119
119
|
type :finite?, '() -> %bool'
|
120
120
|
|
@@ -132,10 +132,10 @@ class Float < Numeric
|
|
132
132
|
type :magnitude, '() -> Float'
|
133
133
|
post(:magnitude) { |r,x| r>=0 }
|
134
134
|
|
135
|
-
type :modulo, '(%integer x {{ x!=0 }}) -> Float'
|
136
|
-
type :modulo, '(Float x {{ x!=0 }}) -> Float'
|
137
|
-
type :modulo, '(Rational x {{ x!=0 }}) -> Float'
|
138
|
-
type :modulo, '(BigDecimal x {{ x!=0 && !self.infinite? && !self.nan? }}) -> BigDecimal'
|
135
|
+
type :modulo, '(%integer x {{ x != 0 }}) -> Float'
|
136
|
+
type :modulo, '(Float x {{ x != 0 }}) -> Float'
|
137
|
+
type :modulo, '(Rational x {{ x != 0 }}) -> Float'
|
138
|
+
type :modulo, '(BigDecimal x {{ x != 0 && !self.infinite? && !self.nan? }}) -> BigDecimal'
|
139
139
|
|
140
140
|
type :nan?, '() -> %bool'
|
141
141
|
|
@@ -148,11 +148,11 @@ class Float < Numeric
|
|
148
148
|
|
149
149
|
type :prev_float, '() -> Float'
|
150
150
|
|
151
|
-
type :quo, '(%integer x {{ x!=0 }}) -> Float'
|
152
|
-
type :quo, '(Float x {{ x!=0 }}) -> Float'
|
153
|
-
type :quo, '(Rational x {{ x!=0 }}) -> Float'
|
154
|
-
type :quo, '(BigDecimal x {{ x!=0 && !self.infinite? && !self.nan? }}) -> BigDecimal'
|
155
|
-
type :quo, '(Complex x {{ x!=0 }}) -> Complex'
|
151
|
+
type :quo, '(%integer x {{ x != 0 }}) -> Float'
|
152
|
+
type :quo, '(Float x {{ x != 0 }}) -> Float'
|
153
|
+
type :quo, '(Rational x {{ x != 0 }}) -> Float'
|
154
|
+
type :quo, '(BigDecimal x {{ x != 0 && !self.infinite? && !self.nan? }}) -> BigDecimal'
|
155
|
+
type :quo, '(Complex x {{ x != 0 }}) -> Complex'
|
156
156
|
pre(:quo) { |x| if (x.real.is_a?(BigDecimal)||x.imaginary.is_a?(BigDecimal)) then (if x.real.is_a?(Float) then (x.real!=Float::INFINITY && !(x.real.nan?)) elsif(x.imaginary.is_a?(Float)) then x.imaginary!=Float::INFINITY && !(x.imaginary.nan?) else true end) && self!=Float::INFINITY && !(self.nan?) else true end && if (x.real.is_a?(Rational) && x.imaginary.is_a?(Float)) then !x.imaginary.nan? else true end}
|
157
157
|
|
158
158
|
type :rationalize, '() -> Rational'
|
@@ -165,7 +165,7 @@ class Float < Numeric
|
|
165
165
|
pre(:round) { !self.infinite? && !self.nan?}
|
166
166
|
|
167
167
|
type :round, '(%numeric) -> %numeric'
|
168
|
-
pre(:round) { |x| x!=0 && if x.is_a?(Complex) then x.imaginary==0 && (if x.real.is_a?(Float)||x.real.is_a?(BigDecimal) then !x.real.infinite? && !x.real.nan? else true end) elsif x.is_a?(Float) then x!=Float::INFINITY && !x.nan? elsif x.is_a?(BigDecimal) then x!=BigDecimal::INFINITY && !x.nan? else true end} #Also, x must be in range [-2**31, 2**31].
|
168
|
+
pre(:round) { |x| x != 0 && if x.is_a?(Complex) then x.imaginary==0 && (if x.real.is_a?(Float)||x.real.is_a?(BigDecimal) then !x.real.infinite? && !x.real.nan? else true end) elsif x.is_a?(Float) then x!=Float::INFINITY && !x.nan? elsif x.is_a?(BigDecimal) then x!=BigDecimal::INFINITY && !x.nan? else true end} #Also, x must be in range [-2**31, 2**31].
|
169
169
|
|
170
170
|
type :to_f, '() -> Float'
|
171
171
|
|
File without changes
|
File without changes
|
@@ -59,13 +59,13 @@ class Integer < Numeric
|
|
59
59
|
type :<=, '(BigDecimal) -> %bool'
|
60
60
|
|
61
61
|
type :<=>, '(%integer) -> Object'
|
62
|
-
post(:<=>) { |r,x| r == -1 || r==0 || r==1}
|
62
|
+
post(:<=>) { |r,x| r == -1 || r == 0 || r == 1 }
|
63
63
|
type :<=>, '(Float) -> Object'
|
64
|
-
post(:<=>) { |r,x| r == -1 || r==0 || r==1}
|
64
|
+
post(:<=>) { |r,x| r == -1 || r == 0 || r == 1 }
|
65
65
|
type :<=>, '(Rational) -> Object'
|
66
|
-
post(:<=>) { |r,x| r == -1 || r==0 || r==1}
|
66
|
+
post(:<=>) { |r,x| r == -1 || r == 0 || r == 1 }
|
67
67
|
type :<=>, '(BigDecimal) -> Object'
|
68
|
-
post(:<=>) { |r,x| r == -1 || r==0 || r==1}
|
68
|
+
post(:<=>) { |r,x| r == -1 || r == 0 || r == 1 }
|
69
69
|
|
70
70
|
type :==, '(Object) -> %bool'
|
71
71
|
|
@@ -81,18 +81,18 @@ class Integer < Numeric
|
|
81
81
|
type :>=, '(Rational) -> %bool'
|
82
82
|
type :>=, '(BigDecimal) -> %bool'
|
83
83
|
|
84
|
-
type :>>, '(%integer) -> %integer r {{ r>=0 }}'
|
84
|
+
type :>>, '(%integer) -> %integer r {{ r >= 0 }}'
|
85
85
|
|
86
86
|
type :[], '(%integer) -> Fixnum'
|
87
87
|
post(:[]) { |r,x| r == 0 || r==1}
|
88
88
|
type :[], '(Rational) -> Fixnum'
|
89
89
|
post(:[]) { |r,x| r == 0 || r==1}
|
90
90
|
type :[], '(Float) -> Fixnum'
|
91
|
-
pre(:[]) { |x| x!=Float::INFINITY && !x.nan? }
|
91
|
+
pre(:[]) { |x| x != Float::INFINITY && !x.nan? }
|
92
92
|
post(:[]) { |r,x| r == 0 || r==1}
|
93
93
|
type :[], '(BigDecimal) -> Fixnum'
|
94
|
-
pre(:[]) { |x| x!=BigDecimal::INFINITY && !x.nan? }
|
95
|
-
post(:[]) { |r,x| r == 0 || r==1}
|
94
|
+
pre(:[]) { |x| x != BigDecimal::INFINITY && !x.nan? }
|
95
|
+
post(:[]) { |r,x| r == 0 || r == 1 }
|
96
96
|
|
97
97
|
type :^, '(%integer) -> %integer'
|
98
98
|
|
File without changes
|
@@ -20,7 +20,7 @@ module Kernel
|
|
20
20
|
type 'self.__dir__', '() -> String or nil'
|
21
21
|
type 'self.__method__', '() -> Symbol or nil'
|
22
22
|
type 'self.`', '(String) -> String'
|
23
|
-
type 'self.abort', '(?String msg) -> %
|
23
|
+
type 'self.abort', '(?String msg) -> %bot'
|
24
24
|
type 'self.at_exit', '() { () -> %any} -> Proc' # TODO: Fix proc
|
25
25
|
type 'self.autoload', '(String or Symbol module, String filename) -> nil'
|
26
26
|
type 'self.autoload?', '(Symbol or String name) -> String or nil'
|
@@ -33,12 +33,12 @@ module Kernel
|
|
33
33
|
# type 'self.catch' # TODO
|
34
34
|
type 'self.eval', '(String, ?Binding, ?String filename, ?Fixnum lineno) -> %any'
|
35
35
|
# type 'self.exec' #TODO
|
36
|
-
type 'self.exit', '(Fixnum or %bool status) -> %
|
37
|
-
type 'self.exit!', '(Fixnum or %bool status) -> %
|
38
|
-
type 'self.fail', '() -> %
|
39
|
-
type 'self.fail', '(String) -> %
|
40
|
-
type 'self.fail', '(Class, Array<String>) -> %
|
41
|
-
type 'self.fail', '(Class, String, Array<String>) -> %
|
36
|
+
type 'self.exit', '(Fixnum or %bool status) -> %bot'
|
37
|
+
type 'self.exit!', '(Fixnum or %bool status) -> %bot'
|
38
|
+
type 'self.fail', '() -> %bot'
|
39
|
+
type 'self.fail', '(String) -> %bot'
|
40
|
+
type 'self.fail', '(Class, Array<String>) -> %bot'
|
41
|
+
type 'self.fail', '(Class, String, Array<String>) -> %bot'
|
42
42
|
# type 'self.fail', '(String or [exception : () -> String], ?String, ?Array<String>) -> %any'
|
43
43
|
# type 'self.fork' #TODO
|
44
44
|
type 'self.format', '(String format, *%any args) -> String'
|
@@ -58,7 +58,7 @@ module Kernel
|
|
58
58
|
type(:proc, "() {(*%any) -> %any} -> Proc") # TODO more precise
|
59
59
|
type 'self.putc', '(Fixnum) -> Fixnum'
|
60
60
|
type 'self.puts', '(*[to_s : () -> String]) -> nil'
|
61
|
-
type 'self.raise', '() -> %
|
61
|
+
type 'self.raise', '() -> %bot'
|
62
62
|
# type 'self.raise', '(String or [exception : () -> String], ?String, ?Array<String>) -> %any'
|
63
63
|
# TODO: above same as fail?
|
64
64
|
type 'self.rand', '(Fixnum or Range max) -> Numeric'
|
@@ -81,9 +81,10 @@ module Kernel
|
|
81
81
|
# type 'self.trap' # TODO
|
82
82
|
# type 'self.untrace_var' # TODO
|
83
83
|
type 'self.warn', '(*String msg) -> nil'
|
84
|
-
type :
|
85
|
-
type :raise, '(
|
86
|
-
type :raise, '(
|
84
|
+
type :clone, '() -> self'
|
85
|
+
type :raise, '() -> %bot'
|
86
|
+
type :raise, '(String) -> %bot'
|
87
|
+
type :raise, '(Class, String, Array<String>) -> %bot'
|
87
88
|
type :send, '(String or Symbol, *%any) -> %any'
|
88
89
|
type :send, '(String or Symbol, *%any) { (*%any) -> %any } -> %any'
|
89
90
|
end
|