PulseExploreJournal ClubDebatesTrendingResearchersJournals
Instagram
HomeExploreJournal ClubTrending
Synapse
⌘+K
Synapse
March 10, 2026ACM Transactions on Software Engineering and Methodology0 citations

FLAT: Formal Languages as Types

View Full Paper
FZFengmin ZhuAZAndreas Zeller

Key Points

  • The aim is to enhance string validation by treating formal languages as types, thus preventing vulnerabilities in programming.
  • Propose a type-based approach using formal languages to distinguish different string types.
  • Implement FLAT-PY, a testing framework for Python that performs runtime type checking.
  • Conduct case studies on real Python code fragments to evaluate the framework's effectiveness.
  • FLAT-PY detected logical bugs in Python code fragments when using random inputs from a language-based fuzzer.
  • Automatic runtime type checking helped identify type errors quickly and efficiently.

Abstract

Programmers regularly use strings to encode many types of data, such as Unix file paths, URLs, and email addresses. They are conceptually different, but existing mainstream programming languages treat them as the same string type . This is problematic: the type system allows, for instance, malicious HTML text to be passed to a function expecting an email address. To distinguish conceptually different string types and to avoid potential vulnerabilities, we regard formal languages as types (FLAT), thereby restricting the set of valid strings using context-free grammars and, if needed, semantic constraints. Applying this type-based approach, we offer a unified solution for string API documentation, input validation, malicious input detection, language-based fuzzing, and test oracles, all at once, based on user-annotated formal language types and, if necessary, preand post-conditions. We implement this idea and present FLAT-PY, a testing framework for Python. By attaching annotations directly to Python code, FLAT-PY automatically performs runtime type checking via code instrumentation and reports any detected type errors as soon as possible. We conducted case studies on real Python code fragments: FLAT-PY can detect logical bugs from random inputs generated by a language-based fuzzer, relying on a reasonable number of user annotations.

Ask AI
Helpful
Bookmark
Share
View Full Paper

Cite This Study

Zhu et al. (2026) studied this question.

synapsesocial.com/papers/69af957570916d39fea4d0f8https://doi.org/10.1145/3799978
Ask AI
Helpful
Bookmark
Share
View Full Paper