-
Notifications
You must be signed in to change notification settings - Fork 88
Release Note 1.3
Steep 1.3.0
is the latest version of Steep 1.3.
Some of the highlights in Steep 1.3 are:
- Add type assertion syntax (#665)
- Add type application syntax (#670)
- Performance improvement (#664, #671, #673, #674)
You can install it with $ gem install steep
or using Bundler.
gem 'steep', '~> 1.3.0'
See the CHANGELOG for the details.
Steep 1.3 introduces two inline type annotations for type assertion and type application.
Type assertion allows declaring type of an expression inline, without introducing new local variable with @type var
annotation.
array = [] #: Array[String]
path = nil #: Pathname?
The type of array
is Array[String]
, instead of Array[untyped]
. And the type of path
is Pathname?
instead of nil
. This is useful especially initializing local variables with empty collection or nil
. The syntax won't look great but this is because of the limitation of comment syntax in Ruby -- it doesn't allow writing a comment in the middle of lines.
Type application is for generic method calls.
table = accounts.each_with_object({}) do |account, table| #$ Hash[String, Account]
table[account.email] = account
end
The each_with_object
method has [T] (T) { (Account, T) -> void } -> T
, and the type application syntax directly specifies the type of T
. So the resulting type is (Hash[String, Account]) { (Account, Hash[String, Account]) -> void } -> Hash[String, Account]
.
The detail of the new syntaxes are explained in the proposal.
Type checking performance of Ruby code is significantly improved since Steep 1.2, up to 2x faster. 🚀
It is done by optimizing type checking core and using #fork
instead of #spawn
if available to start worker processes. Note that if you specify --steep-command
commandline option, it may be unnecessary, and using it forces using #spawn
even if #fork
is available. (The command is left because I'm using the option for profiling -- $ bundle exec steep check --steep-command=bin/steep-prof
.)
- Type narrowing with method calls on case-when has problems. Will be fixed in 1.4.
- No editor completion inside type annotation comments. Will be supported in 1.4.
-
Ruby::FalseAssertion
A type assertion in Ruby code always fails. -
Ruby::UnexpectedTypeArgument
,Ruby::InsufficientTypeArgument
,Ruby::TypeArgumentMismatchError
A type application in Ruby code has errors. -
Signature::InheritModuleError
A class declaration in RBS inherits a module.