Proceedings of the Institute for System Programming of the RAS
RUS  ENG    JOURNALS   PEOPLE   ORGANISATIONS   CONFERENCES   SEMINARS   VIDEO LIBRARY   PACKAGE AMSBIB  
General information
Latest issue
Archive

Search papers
Search references

RSS
Latest issue
Current issues
Archive issues
What is RSS



Proceedings of ISP RAS:
Year:
Volume:
Issue:
Page:
Find






Personal entry:
Login:
Password:
Save password
Enter
Forgotten password?
Register


Proceedings of the Institute for System Programming of the RAS, 2017, Volume 29, Issue 4, Pages 7–20
DOI: https://doi.org/10.15514/ISPRAS-2017-29(4)-1
(Mi tisp232)
 

Automated type contracts generation in Ruby

N. Y. Viuginovab, V. S. Fondaratovb

a St. Petersburg State University
b JetBrains
References:
Abstract: Elegant syntax of the Ruby language pays back when it comes to finding bugs in large codebases. Static analysis is hindered by specific capabilities of Ruby, such as defining methods dynamically and evaluating string expressions. Even in dynamically typed languages, type information is very useful as it ensures better type safety and more reliable checking whether the called method is defined for the object or whether the arguments of the correct types are passed to it. One may annotate the code with YARD (Ruby documentation tool) to declare the input and output types of methods or even declare methods that are added dynamically. These annotations improve the capabilities of tooling such as code completion. This paper reports a new approach to type annotations generation. We trace direct method calls while the program is running, evaluate types of input and output variables and use this information to derive implicit type contracts. Each method or function is associated with a finite-state automaton consisting of all variants of typed signatures for this method. An effective compression technique is applied to the automaton to reduce the cost of storage and allows to display the collected information in a human-readable form. The exhaustiveness of the contract defined by the generated automaton depends on the diversity of the traced method usages. Therefore, it is also important to be able to merge all the automatons received from users into one, which is further covered in this paper.
Keywords: Ruby, dynamically typed languages, Ruby VM, YARV, method signature, type inference, static code analysis.
Bibliographic databases:
Document Type: Article
Language: English
Citation: N. Y. Viuginov, V. S. Fondaratov, “Automated type contracts generation in Ruby”, Proceedings of ISP RAS, 29:4 (2017), 7–20
Citation in format AMSBIB
\Bibitem{ViuFon17}
\by N.~Y.~Viuginov, V.~S.~Fondaratov
\paper Automated type contracts generation in Ruby
\jour Proceedings of ISP RAS
\yr 2017
\vol 29
\issue 4
\pages 7--20
\mathnet{http://mi.mathnet.ru/tisp232}
\crossref{https://doi.org/10.15514/ISPRAS-2017-29(4)-1}
\elib{https://elibrary.ru/item.asp?id=29968640}
Linking options:
  • https://www.mathnet.ru/eng/tisp232
  • https://www.mathnet.ru/eng/tisp/v29/i4/p7
  • Citing articles in Google Scholar: Russian citations, English citations
    Related articles in Google Scholar: Russian articles, English articles
    Proceedings of the Institute for System Programming of the RAS
    Statistics & downloads:
    Abstract page:140
    Full-text PDF :59
    References:23
     
      Contact us:
     Terms of Use  Registration to the website  Logotypes © Steklov Mathematical Institute RAS, 2024