Repository navigation
JSSON v0.0.5.2 — Variable Arithmetic Fix
v0.0.5.2 — Variable Arithmetic Fix
Bug Fixes
Variable Arithmetic Operations 🔧
Fixed a critical bug where arithmetic operations using variables would fail with "unsupported binary operation" errors. Previously, assignment statements (price = 100) were not stored in the symbol table, causing subsequent references to be treated as undefined identifiers instead of their numeric values.
Before (broken):
price = 100
tax = 15
total = price + tax // ❌ Error: unsupported binary operation
After (fixed):
price = 100
tax = 15
total = price + tax // ✅ Works! total = 115
discount = 20
final = total - discount // ✅ final = 95
Technical Details:
- Modified
Transpiler.Transpile()to store assignment values in both the symbol table and output - File:
internal/transpiler/transpiler.go(line 75) - Now assignments can be referenced in subsequent expressions
Examples:
// Chained calculations
quantity = 5
itemPrice = 10
subtotal = quantity * itemPrice // 50
// Mixed operations
base = 100
withTax = base + 15 // 115
withDiscount = withTax - 10 // 105
doubled = withDiscount * 2 // 210
New Features
Compilation Timer ⏱️
Added compilation time measurement to both CLI and playground for performance visibility.
CLI:
$ jsson -i config.jsson > output.json
✓ Compiled in 552.6µs- Auto-formats time units: µs, ms, or s
- Printed to stderr (doesn't interfere with output redirection)
- Helps identify performance bottlenecks
Streaming Support for Large Datasets 🚀
Added streaming infrastructure for efficient handling of large data volumes.
CLI Flags:
# Enable streaming mode
jsson -i large-data.jsson --stream
# Auto-enable for ranges > N items (default: 10,000)
jsson -i data.jsson --stream-threshold 5000Features:
- Memory reduction: ~500MB → < 50MB for 100k items
- Lazy evaluation with
RangeIterator - Automatic threshold detection
Other Improvements
- Added 40+ edge case tests to improve robustness
- Created comprehensive test suite for variable arithmetic