ruby-changes:63389
From: Yusuke <ko1@a...>
Date: Tue, 20 Oct 2020 22:49:04 +0900 (JST)
Subject: [ruby-changes:63389] a3ae90b8c5 (master): NEWS.md: mention TypeProf
https://git.ruby-lang.org/ruby.git/commit/?id=a3ae90b8c5 From a3ae90b8c552e4f98d81284815c50691be7e1a36 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Tue, 20 Oct 2020 13:16:19 +0900 Subject: NEWS.md: mention TypeProf diff --git a/NEWS.md b/NEWS.md index 559bd97..83b7a5a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -83,7 +83,9 @@ sufficient information, see the ChangeLog file or Redmine https://github.com/ruby/ruby/blob/trunk/NEWS.md#L83 * Interpolated String literals are no longer frozen when `# frozen-string-literal: true` is used. [[Feature #17104]] -* RBS is introduced. It is a type definition language for Ruby programs. +* A static analysis foundation is introduced. See "Static analysis" section in detail. + * RBS is introduced. It is a type definition language for Ruby programs. + * TypeProf is experimentally bundled. It is a type analysis tool for Ruby programs. ## Command line options @@ -417,7 +419,9 @@ Excluding feature bug fixes. https://github.com/ruby/ruby/blob/trunk/NEWS.md#L419 * Optimize C method call a little -## RBS +## Statis analysis + +### RBS * RBS is a new language for type definition of Ruby programs. It allows writing types of classes and modules with advanced @@ -428,6 +432,35 @@ Excluding feature bug fixes. https://github.com/ruby/ruby/blob/trunk/NEWS.md#L432 * `rbs` gem is bundled to load and process RBS files. +### TypeProf + +* TypeProf is a type analysis tool for Ruby code based on abstract interpretation. + * It reads non-annotated Ruby code, tries inferring its type signature, and prints + the analysis result in RBS format. + * Though it supports only a subset of the Ruby language yet, we will continuously + improve the coverage of language features, the analysis performance, and usability. + +```ruby +# test.rb +def foo(x) + if x > 10 + x.to_s + else + nil + end +end + +foo(42) +``` + +``` +$ typeprof test.rb +# Classes +class Object + def foo : (Integer) -> String? +end +``` + ## Miscellaneous changes * Methods using `ruby2_keywords` will no longer keep empty keyword -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/