steep 0.1.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/README.md +95 -0
- data/Rakefile +23 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/smoke_runner.rb +106 -0
- data/exe/steep +18 -0
- data/lib/steep.rb +33 -0
- data/lib/steep/annotation.rb +223 -0
- data/lib/steep/cli.rb +79 -0
- data/lib/steep/drivers/check.rb +141 -0
- data/lib/steep/errors.rb +207 -0
- data/lib/steep/interface.rb +280 -0
- data/lib/steep/parser.y +311 -0
- data/lib/steep/signature/class.rb +358 -0
- data/lib/steep/signature/errors.rb +78 -0
- data/lib/steep/signature/extension.rb +51 -0
- data/lib/steep/signature/interface.rb +48 -0
- data/lib/steep/source.rb +98 -0
- data/lib/steep/type_assignability.rb +362 -0
- data/lib/steep/type_construction.rb +993 -0
- data/lib/steep/type_name.rb +37 -0
- data/lib/steep/types.rb +4 -0
- data/lib/steep/types/any.rb +31 -0
- data/lib/steep/types/class.rb +27 -0
- data/lib/steep/types/instance.rb +27 -0
- data/lib/steep/types/merge.rb +32 -0
- data/lib/steep/types/name.rb +57 -0
- data/lib/steep/types/union.rb +42 -0
- data/lib/steep/types/var.rb +38 -0
- data/lib/steep/typing.rb +70 -0
- data/lib/steep/version.rb +3 -0
- data/manual/annotations.md +144 -0
- data/sig/signature.rbi +54 -0
- data/sig/types.rbi +43 -0
- data/smoke/and/a.rb +9 -0
- data/smoke/array/a.rb +22 -0
- data/smoke/block/a.rb +12 -0
- data/smoke/block/a.rbi +4 -0
- data/smoke/case/a.rb +20 -0
- data/smoke/class/a.rb +31 -0
- data/smoke/class/a.rbi +9 -0
- data/smoke/class/b.rb +7 -0
- data/smoke/class/c.rb +10 -0
- data/smoke/const/a.rb +30 -0
- data/smoke/dstr/a.rb +6 -0
- data/smoke/extension/a.rb +11 -0
- data/smoke/extension/a.rbi +8 -0
- data/smoke/extension/b.rb +12 -0
- data/smoke/extension/c.rb +9 -0
- data/smoke/hello/hello.rb +13 -0
- data/smoke/hello/hello.rbi +7 -0
- data/smoke/if/a.rb +20 -0
- data/smoke/implements/a.rb +14 -0
- data/smoke/implements/a.rbi +6 -0
- data/smoke/literal/a.rb +16 -0
- data/smoke/map/a.rb +5 -0
- data/smoke/method/a.rb +26 -0
- data/smoke/method/a.rbi +0 -0
- data/smoke/module/a.rb +21 -0
- data/smoke/module/a.rbi +7 -0
- data/smoke/module/b.rb +8 -0
- data/smoke/self/a.rb +23 -0
- data/smoke/self/a.rbi +4 -0
- data/smoke/super/a.rb +34 -0
- data/smoke/super/a.rbi +10 -0
- data/smoke/yield/a.rb +18 -0
- data/stdlib/builtin.rbi +89 -0
- data/steep.gemspec +32 -0
- metadata +214 -0
data/sig/signature.rbi
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
class Steep__Signature__Error
|
2
|
+
def initialize: (signature: Steep__Signature) -> any
|
3
|
+
def signature: -> Steep__Signature
|
4
|
+
end
|
5
|
+
|
6
|
+
class Steep__Signature__Errors__UnknownTypeName <: Steep__Signature__Error
|
7
|
+
def initialize: (signature: Steep__Signature, type: Steep__Type) -> any
|
8
|
+
def type: -> Steep__Type
|
9
|
+
end
|
10
|
+
|
11
|
+
class Steep__MethodType
|
12
|
+
def substitute: (klass: Steep__Type, instance: Steep__Type, params: Hash<Symbol, Steep__Type>) -> Steep__MethodType
|
13
|
+
end
|
14
|
+
|
15
|
+
class Steep__Interface
|
16
|
+
def initialize: (name: Symbol, methods: Hash<Symbol, Steep__Method>) -> any
|
17
|
+
end
|
18
|
+
|
19
|
+
class Steep__Method
|
20
|
+
def initialize: (types: Array<Steep__MethodType>, super_method: Steep__Method) -> any
|
21
|
+
def substitute: (klass: Steep__Type, instance: Steep__Type, params: Hash<Symbol, Steep__Type>) -> Steep__Method
|
22
|
+
end
|
23
|
+
|
24
|
+
class Steep__Signature
|
25
|
+
end
|
26
|
+
|
27
|
+
class Steep__Signature__Member
|
28
|
+
end
|
29
|
+
|
30
|
+
class Steep__Signature__Errors__IncompatibleOverride <: Steep__Signature__Error
|
31
|
+
def initialize: (signature: Steep__Signature, method_name: Symbol, this_method: Steep__Method, super_method: Steep__Method) -> any
|
32
|
+
def method_name: -> Symbol
|
33
|
+
def this_method: -> Steep__Method
|
34
|
+
def super_method: -> Steep__Method
|
35
|
+
end
|
36
|
+
|
37
|
+
class Steep__Signature__Extension
|
38
|
+
def initialize: (module_name: Symbol, extension_name: Symbol, members: Array<Steep__Signature__Member>) -> any
|
39
|
+
def module_name: -> Symbol
|
40
|
+
def extension_name: -> Symbol
|
41
|
+
def members: -> Array<Steep__Signature__Member>
|
42
|
+
def name: -> Symbol
|
43
|
+
end
|
44
|
+
|
45
|
+
class Steep__Signature__Interface
|
46
|
+
def initialize: (name: Symbol, params: Array<Symbol>, methods: Hash<Symbol, Array<Steep__MethodType>>) -> any
|
47
|
+
|
48
|
+
def name: -> Symbol
|
49
|
+
def params: -> Array<Symbol>
|
50
|
+
def methods: -> Hash<Symbol, Array<Steep__MethodType>>
|
51
|
+
|
52
|
+
def to_interface: (klass: Steep__Type, instance: Steep__Type, params: Array<Steep__Type>) -> any
|
53
|
+
def validate: (any) -> any
|
54
|
+
end
|
data/sig/types.rbi
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
class Steep__TypeName
|
2
|
+
def initialize: (name: Symbol) -> any
|
3
|
+
end
|
4
|
+
|
5
|
+
class Steep__Type
|
6
|
+
def closed?: -> _Boolean
|
7
|
+
def substitute: (klass: Steep__Type, instance: Steep__Type, params: Hash<Symbol, Steep__Type>) -> instance
|
8
|
+
end
|
9
|
+
|
10
|
+
class Steep__Types__Name <: Steep__Type
|
11
|
+
def initialize: (name: Steep__TypeName, params: Array<Steep__Type>) -> any
|
12
|
+
|
13
|
+
def name: -> Steep__TypeName
|
14
|
+
def params: -> Array<Steep__Type>
|
15
|
+
|
16
|
+
def self.interface: (name: Symbol, ?params: Array<Steep__Type>) -> Steep__Types__Name
|
17
|
+
def self.module: (name: Symbol, ?params: Array<Steep__Type>) -> Steep__Types__Name
|
18
|
+
def self.instance: (name: Symbol, ?params: Array<Steep__Type>) -> Steep__Types__Name
|
19
|
+
end
|
20
|
+
|
21
|
+
class Steep__Types__Union <: Steep__Type
|
22
|
+
def initialize: (types: Array<Steep__Type>) -> any
|
23
|
+
def types: -> Array<Steep__Type>
|
24
|
+
end
|
25
|
+
|
26
|
+
class Steep__Types__Merge <: Steep__Type
|
27
|
+
def initialize: (types: Array<Steep__Type>) -> any
|
28
|
+
def types: -> Array<Steep__Type>
|
29
|
+
end
|
30
|
+
|
31
|
+
class Steep__Types__Var <: Steep__Type
|
32
|
+
def initialize: (name: Symbol) -> any
|
33
|
+
def name: -> Symbol
|
34
|
+
end
|
35
|
+
|
36
|
+
class Steep__Types__Instance <: Steep__Type
|
37
|
+
end
|
38
|
+
|
39
|
+
class Steep__Types__Class <: Steep__Type
|
40
|
+
end
|
41
|
+
|
42
|
+
class Steep__Types__Any <: Steep__Type
|
43
|
+
end
|
data/smoke/and/a.rb
ADDED
data/smoke/array/a.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# @type var a: Array<Integer>
|
2
|
+
|
3
|
+
a = []
|
4
|
+
a[1] = 3
|
5
|
+
|
6
|
+
# !expects ArgumentTypeMismatch: type=Array<Integer>, method=[]=
|
7
|
+
a[2] = "foo"
|
8
|
+
|
9
|
+
# @type var i: Integer
|
10
|
+
# @type var s: String
|
11
|
+
|
12
|
+
i = a[0]
|
13
|
+
|
14
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Integer
|
15
|
+
s = a[1]
|
16
|
+
|
17
|
+
|
18
|
+
b = ["a", "b", "c"]
|
19
|
+
|
20
|
+
s = b[0]
|
21
|
+
# !expects IncompatibleAssignment: lhs_type=Integer, rhs_type=String
|
22
|
+
i = b[1]
|
data/smoke/block/a.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# @type var a: A
|
2
|
+
|
3
|
+
a = A.new
|
4
|
+
|
5
|
+
# @type var i: Integer
|
6
|
+
# @type var s: String
|
7
|
+
|
8
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Integer
|
9
|
+
s = a.foo
|
10
|
+
|
11
|
+
# !expects IncompatibleAssignment: lhs_type=Integer, rhs_type=String
|
12
|
+
i = a.foo { nil }
|
data/smoke/block/a.rbi
ADDED
data/smoke/case/a.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# @type var a: Integer
|
2
|
+
|
3
|
+
# !expects IncompatibleAssignment: lhs_type=Integer, rhs_type=Integer | Array<String> | String
|
4
|
+
a = case 1
|
5
|
+
when 2
|
6
|
+
1
|
7
|
+
when 0, 100
|
8
|
+
["String"]
|
9
|
+
when 3
|
10
|
+
nil
|
11
|
+
when 4
|
12
|
+
else
|
13
|
+
"string"
|
14
|
+
end
|
15
|
+
|
16
|
+
a = case
|
17
|
+
# !expects ArgumentTypeMismatch: type=Integer, method=+
|
18
|
+
when 1+"a"
|
19
|
+
nil
|
20
|
+
end
|
data/smoke/class/a.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
class A
|
2
|
+
# @type instance: A
|
3
|
+
# @type module: A.class
|
4
|
+
|
5
|
+
# A#foo is defined and the implementation is compatible.
|
6
|
+
def foo(x)
|
7
|
+
x
|
8
|
+
end
|
9
|
+
|
10
|
+
# A#bar is defined but the implementation is incompatible.
|
11
|
+
# !expects MethodParameterTypeMismatch: method=bar
|
12
|
+
def bar(y)
|
13
|
+
y
|
14
|
+
end
|
15
|
+
|
16
|
+
# Object#to_s is defined but the implementation is incompatible.
|
17
|
+
# !expects MethodBodyTypeMismatch: method=to_s, expected=String, actual=Integer
|
18
|
+
def to_s
|
19
|
+
3
|
20
|
+
end
|
21
|
+
|
22
|
+
# No method definition given via signature, there is no type error.
|
23
|
+
def to_str
|
24
|
+
5
|
25
|
+
end
|
26
|
+
|
27
|
+
# !expects MethodBodyTypeMismatch: method=self.baz, expected=Integer, actual=String
|
28
|
+
def self.baz
|
29
|
+
"baz"
|
30
|
+
end
|
31
|
+
end
|
data/smoke/class/a.rbi
ADDED
data/smoke/class/b.rb
ADDED
data/smoke/class/c.rb
ADDED
data/smoke/const/a.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# @type const A: Integer
|
2
|
+
# @type var x: String
|
3
|
+
|
4
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Integer
|
5
|
+
x = A
|
6
|
+
|
7
|
+
x = B
|
8
|
+
|
9
|
+
module X
|
10
|
+
# @type const A: Integer
|
11
|
+
|
12
|
+
def foo
|
13
|
+
# @type var x: String
|
14
|
+
|
15
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Integer
|
16
|
+
x = A
|
17
|
+
|
18
|
+
x = B
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# @type const Foo::Bar::Baz: Integer
|
24
|
+
|
25
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Integer
|
26
|
+
x = Foo::Bar::Baz
|
27
|
+
|
28
|
+
z = Foo
|
29
|
+
x = z::Bar::Baz
|
30
|
+
x = ::Foo::Bar::Baz
|
data/smoke/dstr/a.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# @type var foo: Foo
|
2
|
+
foo = nil
|
3
|
+
|
4
|
+
# @type var integer: Integer
|
5
|
+
|
6
|
+
# Foo#f returns String because overridden
|
7
|
+
# !expects IncompatibleAssignment: lhs_type=Integer, rhs_type=String
|
8
|
+
integer = foo.f()
|
9
|
+
|
10
|
+
# String#f returns Object because Object(X)#f is used
|
11
|
+
# !expects IncompatibleAssignment: lhs_type=Integer, rhs_type=Object
|
12
|
+
integer = "".f()
|
data/smoke/if/a.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# @type var a: String
|
2
|
+
|
3
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Symbol
|
4
|
+
a = if x
|
5
|
+
:foo
|
6
|
+
end
|
7
|
+
|
8
|
+
if y
|
9
|
+
:foo
|
10
|
+
else
|
11
|
+
"baz"
|
12
|
+
end
|
13
|
+
|
14
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=String | Integer
|
15
|
+
a = if z
|
16
|
+
"foofoo"
|
17
|
+
else
|
18
|
+
3
|
19
|
+
end
|
20
|
+
|
data/smoke/literal/a.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# @type var x: String
|
2
|
+
# @type var y: Integer
|
3
|
+
|
4
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Integer
|
5
|
+
x = 1
|
6
|
+
|
7
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Symbol
|
8
|
+
x = :foo
|
9
|
+
|
10
|
+
# !expects IncompatibleAssignment: lhs_type=Integer, rhs_type=String
|
11
|
+
y = "foo"
|
12
|
+
|
13
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=_Boolean
|
14
|
+
x = true
|
15
|
+
# !expects IncompatibleAssignment: lhs_type=Integer, rhs_type=_Boolean
|
16
|
+
y = false
|
data/smoke/map/a.rb
ADDED
data/smoke/method/a.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# @type method foo: (Integer, y: Integer) -> String
|
2
|
+
|
3
|
+
# !expects MethodBodyTypeMismatch: method=foo, expected=String, actual=Integer
|
4
|
+
def foo(x, y:)
|
5
|
+
# @type var z: String
|
6
|
+
|
7
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Integer
|
8
|
+
z = x
|
9
|
+
|
10
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Integer
|
11
|
+
z = y
|
12
|
+
|
13
|
+
3
|
14
|
+
end
|
15
|
+
|
16
|
+
# @type method bar: (Integer) -> String
|
17
|
+
|
18
|
+
# !expects MethodParameterTypeMismatch: method=bar
|
19
|
+
def bar(x, y)
|
20
|
+
# @type var z: String
|
21
|
+
|
22
|
+
# !expects IncompatibleAssignment: lhs_type=String, rhs_type=Integer
|
23
|
+
z = x
|
24
|
+
|
25
|
+
z = y
|
26
|
+
end
|