Skip to content

v3.2.0

Choose a tag to compare

@johnnyt johnnyt released this 31 Aug 11:53
· 431 commits to main since this release
efa6b83

[3.2.0] - 2025-08-31

Added

Strict Equality Operators

  • New Operators: Added === (strict equality) and !== (strict inequality) operators
  • Type-Safe Comparisons: Strict operators compare both value and type, unlike loose equality
  • Round-Trip Preservation: Operators maintain their exact form during parse/decompile cycles
  • Complete Pipeline Support: Full lexer, parser, evaluator, and visitor implementation
  • Comprehensive Testing: 23 tests covering all aspects of strict equality functionality

Examples

# Strict equality - same type and value required
Predicator.evaluate("5 === 5", %{})      # {:ok, true}
Predicator.evaluate("5 === '5'", %{})    # {:ok, false} - different types

# Strict inequality - true when type or value differs
Predicator.evaluate("5 !== '5'", %{})    # {:ok, true} - different types
Predicator.evaluate("1 !== true", %{})   # {:ok, true} - different types

# Operator distinction preserved
Predicator.parse("x = y") |> elem(1) |> Predicator.decompile()   # "x = y"
Predicator.parse("x == y") |> elem(1) |> Predicator.decompile()  # "x == y"  
Predicator.parse("x === y") |> elem(1) |> Predicator.decompile() # "x === y"

Technical Implementation

  • Lexer: Added :strict_equal and :strict_ne token types with proper precedence
  • Parser: Extended comparison grammar to support strict operators
  • Evaluator: Added STRICT_EQ and STRICT_NE instruction handlers
  • StringVisitor: Added decompilation support for round-trip accuracy
  • Type Safety: Works with all data types including :undefined values