Typing Ruby is a type checker for ruby programs. It statically analyzes ruby programs and finds type errors. The type check cannot be complete but can help your debugging and testing.
Typing Ruby uses a Duck Typing compatible type checking algorithm, so it's check is almost compatible with Ruby's run-time type check. The target of Typing Ruby is pure ruby language (with no language extensions), so you don't have to rewrite your programs to check.
Currently, Typing Ruby is in pre-alpha stage. It only checks very trivial programs now.
# | Program | Comments | ||
---|---|---|---|---|
01 |
123.hoge() |
ERROR | NO_METHOD_ERROR | Fixnum#hoge is not defined. |
02 |
x = 123 x.foo() |
ERROR | NO_METHOD_ERROR | Variable assignment is supported. |
03 |
def foo(x) x.hoge() end foo(123) |
ERROR | NO_METHOD_ERROR | User defined method is supported. |
04 |
def foo(x) x.to_s() end foo(123).bar() |
ERROR | NO_METHOD_ERROR | foo returns String object and String#bar is not defined. |
Currently, "If", "While", and other ruby's statements are not supported. Also instance variables and global variables are not supported. You can't check programs including a class definition inherits another.
Your programs can only call methods or functions, define classes and instance methods.
Typing Ruby is a free software with ABSOLUTELY NO WARRANTY under the terms of the GNU GPL2 (or Ruby's License).
No files are released now (07 Jan 2005). The first release will be available soon. Please wait.
You can check out the source code from Subversion repository anonymously. The source code checked out from the repository may be impossible to build.
Maybe, it is possible to build and use under different versions.
NodeDump is a ruby's extension library to dump syntax tree nodes parsed by the parser of the original ruby. Typing Ruby uses hacked version NodeDump to avoid write a parser from scratch.
To install NodeDump-truby, run the following commands.
$ tar xfz nodedump-truby-xyz.tgz $ cd nodedump-truby-xyz $ ruby ./extconf.rb $ make $ su # make install
To build truby, run the following commands.
$ tar xfz truby-xyz.tgz $ cd truby-xyz $ make release
You don't have to install Typing Ruby into your system. Instead, you can try it in the build directory.
Use the truby command. If you don't set the input file name, then truby reads ruby program from the standard input.
$ ./truby foo.rb $ ./truby
The truby process invokes ruby with "-r NodeDumpT" option and make parse the source code. If you want to pass some additional options, use -r option or use --ruby-option option.
$ ./truby -r "some additional options for ruby" bar.rb $ ./truby --ruby-option="some additional options for ruby" baz.rb
Note that if you want to pass option by short-option style, you have to insert a white space in the head of ruby option. If you set a option like $ ./truby -r -a foo.rb, then the Getopt command-line option parser gets confused and raises an error. So you have to set "-a" option like $ ./truby -r " -a" foo.rb, or $ ./truby -r"-a" foo.rb. Of course, you can use the long option style of --ruby-option instead.
MATSUMOTO Soutaro < soutaro@score.cs.tsukuba.ac.jp >
$Date: 2005-02-22 03:52:41 +0900 (Tue, 22 Feb 2005) $