Skip to content

Release Note 1.2

Soutaro Matsumoto edited this page Oct 22, 2022 · 2 revisions

Steep 1.2.1 is the latest version of Steep 1.2.

Some of the highlights in Steep 1.2 are:

  1. Support type checking block/proc self type binding (#637)
  2. Better multiple assignment support (#641, #630)
  3. steep checkfile command (#650)

You can install it with $ gem install steep or using bundler.

gem 'steep', '~> 1.2.0'

See the CHANGELOG for the details.

Support type checking block/proc self type binding

RBS 2.7 introduces new syntax that allows defining the type of instance_eval -- the self inside block is bound to another object. Steep 1.2 supports type checking method calls with self-type-binding.

Type checking #instance_eval call

Note that blocks/procs with self-type-binding are incomaptible with blocks/procs without self-type-binding.

Type error caused by self-type-binding

The proc in the example above has self-type-binding [self: String], and it cannot be passed to #yield_self method where the required block is without self-type-binding.

Better multiple assignment support

There are two improvements related to multiple assignments.

Multiple assignments in block parameters are now supported.

# @type var hash: Hash[Symbol, [Integer, String]]
hash.each do |key, (number, string)|
  # number is Integer and string is String
end

Multiple assignment with union type right hand side can be supported. This happens typically with conditionals.

x, y = test ? [1, "foo"] : [:symbol, nil]

The right hand side of the multiple assignment is a union type, [Integer, String] | [Symbol, nil], and Steep 1.2 distributes the union over the tuples, [Integer | Symbol, String?]. The x and y local variables will have type of Integer | Symbol and String?.

steep checkfile command

The new subcommand is to support integrations to editors, not based on LSP.

The editor will run the command on open files, Steep type checks given files, and editor will show the diagnostics on its buffers. Without some of the advanced features like completion, but easier to integrate.

See the spec for details.

Upgrading

One note about upgrading to Steep 1.2 from 1.1.x is performance degrade. Unfortunately, 1.2.0 runs roughly two times slower than 1.1.1. I haven't found possible changes to improve the performance enough.

Known issues

  • Type narrowing with method calls on case-when has problems. Will be fixed in 1.3.