Invariances

The goal of SemanticDiff is to help you focus on the relevant changes. To achieve this, SemanticDiff tries to hide changes that do not affect the execution of the program. These invariances can be divided into two categories. The first category contains changes that do not modify the program on a syntactic level. This is usually defined by the grammar of the programming language and includes things like line breaks between parameters or optional commas. The second category contains changes that modify the code on a syntactic level but that do not change the semantics of a program. An example would be replacing for(;;) with while(1).

In the following sections we give an overview of the invariances supported by SemanticDiff. We will mainly focus on the second category (semantic equivalence).

C#

  • Adding/Removing unnecessary parenthesis
  • Changing the base of an integer literal
  • Escaping characters in strings

CSS

(Only syntactic equivalence)

Go

  • Adding/Removing unnecessary parenthesis
  • Changing the base of an integer literal
  • Escaping characters in strings
  • Reordering of type elements in a type term

Java

  • Adding/Removing unnecessary parenthesis
  • Changing the base of an integer literal
  • Escaping characters in strings

JavaScript / JSX

  • Adding/Removing unnecessary parenthesis
  • Changing the base of an integer literal
  • Escaping characters in strings
  • Reordering keys in an object declaration
  • Converting between an anonymous/arrow function

JSON5

  • Changing the base of an integer literal
  • Escaping characters in strings
  • Reordering of keys

Gettext .po

  • Escaping characters in strings
  • Reordering of messages

Python

  • Adding/Removing unnecessary parenthesis
  • Changing the base of an integer literal
  • Escaping characters in strings
  • Splitting / combining of strings
  • Reordering of keyword arguments

Rust

  • Adding/Removing unnecessary parenthesis
  • Changing the base of an integer literal
  • Escaping characters in a string/char
  • Exchanging the deprecated ... range operator with ..=

SCSS

(Only syntactic equivalence)

TypeScript / TSX

  • Adding/Removing unnecessary parenthesis
  • Changing the base of an integer literal
  • Escaping characters in strings
  • Reordering keys in an object declaration
  • Converting between an anonymous/arrow function