Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Demo (lack of) type narrowing.

Notifications You must be signed in to change notification settings

smockle-archive/rbs_steep_demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RBS Steep Demo

Demo (lack of) type narrowing.

Usage

  1. Clone this repo.

  2. Install dependencies: bundle install

  3. Check types with Steep: bundle exec steep check rbs_steep_demo.rb

  4. Note the following error is reported:

    rbs_steep_demo.rb:12:18: [error] Type `(::Integer | nil)` does not have method `+`
    │ Diagnostic ID: Ruby::NoMethod
    │
    └     @maybe_number + 1
                        ~
    
    Detected 1 problem from 1 file
    
  5. Consider that the early return on rbs_steep_demo.rb#L10 (return if @maybe_number.nil?) should narrow the type of @maybe_number to Integer, and that Integer has a method +.

References

About

Demo (lack of) type narrowing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages