Skip to content
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
4 changes: 2 additions & 2 deletions doc/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _type_ ::= _class-name_ _type-arguments_ (Class instance type)
| `instance`
| `class`
| `bool`
| `any`
| `untyped`
| `nil`
| `top`
| `bot`
Expand Down Expand Up @@ -179,7 +179,7 @@ Proc type denots type of procedures, `Proc` instances.

`bool` is an abstract type for truth value.

`any` is for _a type without type checking_. It is `?` in gradual typing, _dynamic_ in some other languages. Subtype _and_ supertype of all of the types.
`untyped` is for _a type without type checking_. It is `?` in gradual typing, _dynamic_ in some languages like C#, and _any_ in TypeScript. It is both subtype _and_ supertype of all of the types. (The type was `any` but renamed to `untyped`.)

`nil` is for _nil_.

Expand Down
9 changes: 7 additions & 2 deletions lib/ruby/signature/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Ruby::Signature::Parser
tANNOTATION
tSTRING tSYMBOL tINTEGER tWRITE_ATTR
kLPAREN kRPAREN kLBRACKET kRBRACKET kLBRACE kRBRACE
kVOID kNIL kANY kTOP kBOT kSELF kSELFQ kINSTANCE kCLASS kBOOL kSINGLETON kTYPE kDEF kMODULE kSUPER
kVOID kNIL kANY kUNTYPED kTOP kBOT kSELF kSELFQ kINSTANCE kCLASS kBOOL kSINGLETON kTYPE kDEF kMODULE kSUPER
kPRIVATE kPUBLIC kALIAS
kCOLON kCOLON2 kCOMMA kBAR kAMP kHAT kARROW kQUESTION kEXCLAMATION kSTAR kSTAR2 kFATARROW kEQ kDOT kLT
kINTERFACE kEND kINCLUDE kEXTEND kATTRREADER kATTRWRITER kATTRACCESSOR tOPERATOR tQUOTEDMETHOD
Expand Down Expand Up @@ -501,7 +501,7 @@ rule
method_name0: tUIDENT | tLIDENT | identifier_keywords

identifier_keywords:
kCLASS | kVOID | kNIL | kANY | kTOP | kBOT | kINSTANCE | kBOOL | kSINGLETON
kCLASS | kVOID | kNIL | kANY | kUNTYPED | kTOP | kBOT | kINSTANCE | kBOOL | kSINGLETON
| kTYPE | kMODULE | kPRIVATE | kPUBLIC | kEND | kINCLUDE | kEXTEND | kPREPEND
| kATTRREADER | kATTRACCESSOR | kATTRWRITER | kDEF | kEXTENSION | kSELF | kINCOMPATIBLE

Expand Down Expand Up @@ -611,6 +611,10 @@ rule
result = Types::Bases::Void.new(location: val[0].location)
}
| kANY {
Ruby::Signature.logger.warn "`any` type is deprecated. Use `untyped` instead. (#{val[0].location.to_s})"
result = Types::Bases::Any.new(location: val[0].location)
}
| kUNTYPED {
result = Types::Bases::Any.new(location: val[0].location)
}
| kBOOL {
Expand Down Expand Up @@ -1106,6 +1110,7 @@ KEYWORDS = {
"self" => :kSELF,
"void" => :kVOID,
"any" => :kANY,
"untyped" => :kUNTYPED,
"top" => :kTOP,
"bot" => :kBOT,
"instance" => :kINSTANCE,
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby/signature/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def to_s(level = 0)
when Types::Bases::Void
'void'
when Types::Bases::Any
'any'
'untyped'
when Types::Bases::Nil
'nil'
when Types::Bases::Top
Expand Down
50 changes: 25 additions & 25 deletions stdlib/builtin/array.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ class Array[Elem] < Object
def *: (Integer arg0) -> ::Array[Elem]
| (String arg0) -> String

def +: (::Enumerable[Elem, any] arg0) -> ::Array[Elem]
def +: (::Enumerable[Elem, untyped] arg0) -> ::Array[Elem]
| (::Array[Elem] arg0) -> ::Array[Elem]

def -: (::Array[any] arg0) -> ::Array[Elem]
def -: (::Array[untyped] arg0) -> ::Array[Elem]

def <<: (Elem arg0) -> ::Array[Elem]

Expand Down Expand Up @@ -359,7 +359,7 @@ class Array[Elem] < Object
def collect: [U] () { (Elem arg0) -> U } -> ::Array[U]
| () -> ::Enumerator[Elem, self]

def combination: (Integer arg0) { (::Array[Elem] arg0) -> any } -> ::Array[Elem]
def combination: (Integer arg0) { (::Array[Elem] arg0) -> untyped } -> ::Array[Elem]
| (Integer arg0) -> ::Enumerator[::Array[Elem], self]

# This is implemented in C++ to fix the return type
Expand All @@ -369,7 +369,7 @@ class Array[Elem] < Object
# [ "a", nil, "b", nil, "c", nil ].compact
# #=> [ "a", "b", "c" ]
# ```
def compact: () -> ::Array[any]
def compact: () -> ::Array[untyped]

# Removes `nil` elements from the array.
#
Expand Down Expand Up @@ -399,30 +399,30 @@ class Array[Elem] < Object
# ```
def count: () -> Integer
| (?Elem arg0) -> Integer
| () { (Elem arg0) -> any } -> Integer
| () { (Elem arg0) -> untyped } -> Integer

def cycle: (?Integer arg0) { (Elem arg0) -> any } -> any
def cycle: (?Integer arg0) { (Elem arg0) -> untyped } -> untyped
| (?Integer arg0) -> ::Enumerator[Elem, self]

def delete: (Elem arg0) -> Elem?
| (Elem arg0) { () -> Elem } -> Elem

def delete_at: (Integer arg0) -> Elem?

def delete_if: () { (Elem arg0) -> any } -> ::Array[Elem]
def delete_if: () { (Elem arg0) -> untyped } -> ::Array[Elem]
| () -> ::Enumerator[Elem, self]

def difference: (*::Array[any] arrays) -> ::Array[Elem]
def difference: (*::Array[untyped] arrays) -> ::Array[Elem]

def drop: (Integer arg0) -> ::Array[Elem]

def drop_while: () { (Elem arg0) -> any } -> ::Array[Elem]
def drop_while: () { (Elem arg0) -> untyped } -> ::Array[Elem]
| () -> ::Enumerator[Elem, self]

def each: () -> ::Enumerator[Elem, self]
| () { (Elem arg0) -> any } -> ::Array[Elem]
| () { (Elem arg0) -> untyped } -> ::Array[Elem]

def each_index: () { (Integer arg0) -> any } -> ::Array[Elem]
def each_index: () { (Integer arg0) -> untyped } -> ::Array[Elem]
| () -> ::Enumerator[Elem, self]

# Returns `true` if `self` contains no elements.
Expand Down Expand Up @@ -475,12 +475,12 @@ class Array[Elem] < Object
# a = [ 1, 2, [3, [4, 5] ] ]
# a.flatten(1) #=> [1, 2, 3, [4, 5]]
# ```
def flatten: (?Integer depth) -> ::Array[any]
def flatten: (?Integer depth) -> ::Array[untyped]

def `include?`: [U] (U arg0) -> bool

def index: [U] (?U arg0) -> Integer?
| () { (Elem arg0) -> any } -> Integer?
| () { (Elem arg0) -> untyped } -> Integer?
| () -> ::Enumerator[Elem, self]

def initialize: () -> Object
Expand All @@ -502,7 +502,7 @@ class Array[Elem] < Object

def join: (?String arg0) -> String

def keep_if: () { (Elem arg0) -> any } -> ::Array[Elem]
def keep_if: () { (Elem arg0) -> untyped } -> ::Array[Elem]

# Returns the last element(s) of `self` . If the array is empty, the first
# form returns `nil` .
Expand Down Expand Up @@ -539,7 +539,7 @@ class Array[Elem] < Object
def member?: (Elem arg0) -> bool

def permutation: (?Integer arg0) -> ::Enumerator[::Array[Elem], self]
| (?Integer arg0) { (::Array[Elem] arg0) -> any } -> ::Array[Elem]
| (?Integer arg0) { (::Array[Elem] arg0) -> untyped } -> ::Array[Elem]

def pop: (?Integer arg0) -> ::Array[Elem]
| () -> Elem?
Expand All @@ -552,16 +552,16 @@ class Array[Elem] < Object

def rassoc: [U] (U arg0) -> Elem?

def reject: () { (Elem arg0) -> any } -> ::Array[Elem]
def reject: () { (Elem arg0) -> untyped } -> ::Array[Elem]
| () -> ::Enumerator[Elem, self]

def reject!: () { (Elem arg0) -> any } -> ::Array[Elem]
def reject!: () { (Elem arg0) -> untyped } -> ::Array[Elem]
| () -> ::Enumerator[Elem, self]

def repeated_combination: (Integer arg0) { (::Array[Elem] arg0) -> any } -> ::Array[Elem]
def repeated_combination: (Integer arg0) { (::Array[Elem] arg0) -> untyped } -> ::Array[Elem]
| (Integer arg0) -> ::Enumerator[::Array[Elem], self]

def repeated_permutation: (Integer arg0) { (::Array[Elem] arg0) -> any } -> ::Array[Elem]
def repeated_permutation: (Integer arg0) { (::Array[Elem] arg0) -> untyped } -> ::Array[Elem]
| (Integer arg0) -> ::Enumerator[::Array[Elem], self]

# Returns a new array containing `self` ‘s elements in reverse order.
Expand All @@ -581,11 +581,11 @@ class Array[Elem] < Object
# ```
def reverse!: () -> ::Array[Elem]

def reverse_each: () { (Elem arg0) -> any } -> ::Array[Elem]
def reverse_each: () { (Elem arg0) -> untyped } -> ::Array[Elem]
| () -> ::Enumerator[Elem, self]

def rindex: (?Elem arg0) -> Integer?
| () { (Elem arg0) -> any } -> Integer?
| () { (Elem arg0) -> untyped } -> Integer?
| () -> ::Enumerator[Elem, self]

def rotate: (?Integer arg0) -> ::Array[Elem]
Expand All @@ -595,10 +595,10 @@ class Array[Elem] < Object
def sample: () -> Elem?
| (?Integer arg0) -> ::Array[Elem]

def select: () { (Elem arg0) -> any } -> ::Array[Elem]
def select: () { (Elem arg0) -> untyped } -> ::Array[Elem]
| () -> ::Enumerator[Elem, self]

def select!: () { (Elem arg0) -> any } -> ::Array[Elem]
def select!: () { (Elem arg0) -> untyped } -> ::Array[Elem]
| () -> ::Enumerator[Elem, self]

# Removes the first element of `self` and returns it (shifting all other
Expand Down Expand Up @@ -709,7 +709,7 @@ class Array[Elem] < Object

def take: (Integer arg0) -> ::Array[Elem]

def take_while: () { (Elem arg0) -> any } -> ::Array[Elem]
def take_while: () { (Elem arg0) -> untyped } -> ::Array[Elem]
| () -> ::Enumerator[Elem, self]

# Returns `self` .
Expand All @@ -723,7 +723,7 @@ class Array[Elem] < Object

def transpose: () -> ::Array[Elem]

def union: (*::Array[any] arrays) -> ::Array[any]
def union: (*::Array[untyped] arrays) -> ::Array[untyped]

# Returns a new array by removing duplicate values in `self` .
#
Expand Down
12 changes: 6 additions & 6 deletions stdlib/builtin/basic_object.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ class BasicObject
# Boolean negate.
def !: () -> bool

def !=: (any other) -> bool
def !=: (untyped other) -> bool

def ==: (any other) -> bool
def ==: (untyped other) -> bool

# Returns an integer identifier for `obj` .
#
Expand All @@ -86,14 +86,14 @@ class BasicObject
# ```
def __id__: () -> Integer

def __send__: (Symbol arg0, *any arg1) -> any
def __send__: (Symbol arg0, *untyped arg1) -> untyped

def equal?: (any other) -> bool
def equal?: (untyped other) -> bool

def instance_eval: (?String arg0, ?String filename, ?Integer lineno) -> any
def instance_eval: (?String arg0, ?String filename, ?Integer lineno) -> untyped
| [U] () { () -> U } -> U

def instance_exec: [U, V] (*V args) { (any args) -> U } -> U
def instance_exec: [U, V] (*V args) { (untyped args) -> U } -> U

private
def initialize: () -> void
Expand Down
4 changes: 2 additions & 2 deletions stdlib/builtin/binding.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Binding < Object
# ```ruby
# binding.eval("#{symbol}")
# ```
def local_variable_get: (String | Symbol symbol) -> any
def local_variable_get: (String | Symbol symbol) -> untyped

# Set local variable named `symbol` as `obj`.
#
Expand All @@ -90,7 +90,7 @@ class Binding < Object
# ```
#
# if `obj` can be dumped in Ruby code.
def local_variable_set: (String | Symbol symbol, any obj) -> any
def local_variable_set: (String | Symbol symbol, untyped obj) -> untyped

# Returns the bound receiver of the binding object.
def receiver: () -> Object
Expand Down
10 changes: 5 additions & 5 deletions stdlib/builtin/class.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ class Class < Module
#
# klass.allocate.initialized? #=> false
# ```
def allocate: () -> any
def allocate: () -> untyped

# Sorbet hijacks Class#new to re-use the sig from MyClass#initialize when creating new instances of a class.
# This method must be here so that all calls to MyClass.new aren't forced to take 0 arguments.
# Calls `allocate` to create a new object of *class* ’s class, then
# invokes that object’s `initialize` method, passing it *args* . This is
# the method that ends up getting called whenever an object is constructed
# using .new.
def new: (*any args) -> any
def new: (*untyped args) -> untyped

def inherited: (Class arg0) -> any
def inherited: (Class arg0) -> untyped

def instance_methods: (?bool arg0) -> ::Array[Symbol]

Expand All @@ -117,6 +117,6 @@ class Class < Module

def initialize: () -> void
| (?Class superclass) -> void
| () { (Class arg0) -> any } -> void
| (?Class superclass) { (Class arg0) -> any } -> void
| () { (Class arg0) -> untyped } -> void
| (?Class superclass) { (Class arg0) -> untyped } -> void
end
14 changes: 7 additions & 7 deletions stdlib/builtin/comparable.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@
module Comparable
# Compares two objects based on the receiver’s `<=>` method, returning
# true if it returns -1.
def <: (any other) -> bool
def <: (untyped other) -> bool

# Compares two objects based on the receiver’s `<=>` method, returning
# true if it returns -1 or 0.
def <=: (any other) -> bool
def <=: (untyped other) -> bool

# Compares two objects based on the receiver’s `<=>` method, returning
# true if it returns 0. Also returns true if *obj* and *other* are the
# same object.
def ==: (any other) -> bool
def ==: (untyped other) -> bool

# Compares two objects based on the receiver’s `<=>` method, returning
# true if it returns 1.
def >: (any other) -> bool
def >: (untyped other) -> bool

# Compares two objects based on the receiver’s `<=>` method, returning
# true if it returns 0 or 1.
def >=: (any other) -> bool
def >=: (untyped other) -> bool

# Returns `false` if *obj* `<=>` *min* is less than zero or if *anObject*
# `<=>` *max* is greater than zero, `true` otherwise.
Expand All @@ -64,7 +64,7 @@ module Comparable
# 'cat'.between?('ant', 'dog') #=> true
# 'gnu'.between?('ant', 'dog') #=> false
# ```
def between?: (any min, any max) -> bool
def between?: (untyped min, untyped max) -> bool

# Returns *min* if *obj* `<=>` *min* is less than zero, *max* if *obj*
# `<=>` *max* is greater than zero and *obj* otherwise.
Expand All @@ -77,5 +77,5 @@ module Comparable
# 'd'.clamp('a', 'f') #=> 'd'
# 'z'.clamp('a', 'f') #=> 'f'
# ```
def clamp: (any min, any max) -> any
def clamp: (untyped min, untyped max) -> untyped
end
8 changes: 4 additions & 4 deletions stdlib/builtin/dir.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Dir < Object

def self.exist?: (String file) -> bool

def self.foreach: (String dir, ?Encoding arg0) { (String arg0) -> any } -> NilClass
def self.foreach: (String dir, ?Encoding arg0) { (String arg0) -> untyped } -> NilClass
| (String dir, ?Encoding arg0) -> ::Enumerator[String, self]

# Returns the path to the current working directory of this process as a
Expand All @@ -33,7 +33,7 @@ class Dir < Object
def self.getwd: () -> String

def self.glob: (String | ::Array[String] pattern, ?Integer flags) -> ::Array[String]
| (String | ::Array[String] pattern, ?Integer flags) { (String arg0) -> any } -> NilClass
| (String | ::Array[String] pattern, ?Integer flags) { (String arg0) -> untyped } -> NilClass

def self.home: (?String arg0) -> String

Expand Down Expand Up @@ -65,7 +65,7 @@ class Dir < Object
# ```
def close: () -> NilClass

def each: () { (String arg0) -> any } -> self
def each: () { (String arg0) -> untyped } -> self
| () -> ::Enumerator[String, self]

# Returns the file descriptor used in *dir* .
Expand Down Expand Up @@ -140,5 +140,5 @@ class Dir < Object
def to_path: () -> String?

def self.[]: (String | ::Array[String] pattern, ?Integer flags) -> ::Array[String]
| (String | ::Array[String] pattern, ?Integer flags) { (String arg0) -> any } -> NilClass
| (String | ::Array[String] pattern, ?Integer flags) { (String arg0) -> untyped } -> NilClass
end
2 changes: 1 addition & 1 deletion stdlib/builtin/encoding.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Encoding < Object
# "SJIS"=>"Shift_JIS", "eucJP"=>"EUC-JP", "CP932"=>"Windows-31J"}
def self.aliases: () -> ::Hash[String, String]

def self.compatible?: (any obj1, any obj2) -> Encoding?
def self.compatible?: (untyped obj1, untyped obj2) -> Encoding?

# Returns default external encoding.
#
Expand Down
Loading