Skip to content

fix: return na for empty array calculations#68

Merged
luisleo526 merged 1 commit into
mainfrom
fix/ki48-empty-array-aggregates
Jul 17, 2026
Merged

fix: return na for empty array calculations#68
luisleo526 merged 1 commit into
mainfrom
fix/ki48-empty-array-aggregates

Conversation

@luisleo526

Copy link
Copy Markdown
Contributor

Summary

  • return typed numeric na for empty array sum/avg/min/max/range, stdev/variance, median/mode, percentiles, and covariance before unsafe STL access or division
  • preserve Pine argument evaluation: stateful scalar arguments are bound exactly once before the empty guard, while temporary receivers remain receiver-first
  • make covariance safe for temporary peer arrays and preserve standardize(empty) as an empty array

TradingView documents empty numeric array calculations as na, except standardize, which returns an empty array: https://www.tradingview.com/pine-script-docs/language/arrays/

This is KI-48 stage 1 only. Mixed-NA filtering, negative/OOB access, and insert/fill/slice range errors remain separate stages.

Regression evidence

  • focused semantic and compile review: 28/28, independent GO
  • full engine-enabled pytest: exit 0, 1,651 collected with only 2 pre-existing skips
  • corpus transpile/compile: 254/254
  • gate selftest: 18/18
  • full Pyodide parity: 277/277
  • full 796-source baseline/candidate census: 779 OK + identical 17 errors, 0 status changes, exactly 15 generated-output changes
  • 5 affected public Excellent strategies: candidate engine tapes byte-identical
  • 2 affected public corpus strategies: candidate tapes byte-identical and still Excellent
  • git diff --check clean

Expected public score impact: neutral. This fixes latent wrong-value/undefined-behavior paths without changing any currently exercised nonempty result.

@luisleo526
luisleo526 merged commit f2f1488 into main Jul 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant