littlewing 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -513,6 +513,9 @@ declare class Parser {
513
513
  private getPrecedence;
514
514
  /**
515
515
  * Get unary operator precedence
516
+ * Returns 6 which is higher than add/sub (6) but lower than exponentiation (8)
517
+ * This means: -2^2 parses as -(2^2) = -4, not (-2)^2 = 4
518
+ * This matches the behavior of Python, Ruby, and most languages
516
519
  */
517
520
  private getUnaryPrecedence;
518
521
  /**
package/dist/index.js CHANGED
@@ -923,11 +923,15 @@ function analyzeProgram(node) {
923
923
  const deps = new Set;
924
924
  const hasFunctionCall = collectDependencies(stmt.value, deps);
925
925
  dependencies.set(varName, deps);
926
- if (count === 0 && isNumberLiteral(stmt.value)) {
927
- constants.set(varName, stmt.value.value);
928
- }
929
- if (hasFunctionCall) {
926
+ if (isNullishAssignment(stmt)) {
930
927
  tainted.add(varName);
928
+ } else {
929
+ if (count === 0 && isNumberLiteral(stmt.value)) {
930
+ constants.set(varName, stmt.value.value);
931
+ }
932
+ if (hasFunctionCall) {
933
+ tainted.add(varName);
934
+ }
931
935
  }
932
936
  }
933
937
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "littlewing",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "A minimal, high-performance arithmetic expression language with lexer, parser, and executor. Optimized for browsers with zero dependencies and type-safe execution.",
5
5
  "keywords": [
6
6
  "arithmetic",