Skip to content

fix(compiler): preserve nested empty object defaults (#101) - #114

Open
amazingjoe wants to merge 1 commit into
salesforce:mainfrom
amazingjoe:fix-issue-101
Open

amazingjoe wants to merge 1 commit into
salesforce:mainfrom
amazingjoe:fix-issue-101

Conversation

@amazingjoe

Copy link
Copy Markdown
Contributor

What

Preserve nested empty objects in compiled variable defaults, retaining object properties and list lengths and element positions.

Why

extractDictExpression() returned undefined for empty dictionaries. Recursive extraction then omitted those values from parent objects and filtered them out of lists, without emitting diagnostics.

Fixes #101

How

Return the extracted dictionary even when it is empty. Missing/non-dictionary inputs and unsupported expressions continue to return undefined. Existing dictionary-key prototype protection is preserved.

The production change is confined to packages/compiler/src/ast-helpers.ts. Regression tests were added to four existing compiler test files.

Test Plan

Added 16 tests using the existing Vitest framework:

  • 5 variable-default regressions covering nested empty objects and list positions.
  • 4 extraction regressions covering dictionaries, list literals, and plain arrays.
  • 3 compatibility controls for missing, non-dictionary, and unsupported inputs.
  • 2 model configuration regressions covering inheritance and overrides.
  • 2 live parameter regressions.

Existing test assertions were retained. Here is what the latest regression test suite looks like before/after the fixes.

Compiler tests Before fix After fix
Existing tests 1,327 passed; 3 skipped 1,327 passed; 3 skipped
New compatibility controls 3 passed 3 passed
New bug regressions 13 failed 13 passed
Total 1,330 passed; 13 failed; 3 skipped 1,343 passed; 0 failed; 3 skipped

The original issue reproduction now preserves both defaults:

Variable Before fix After fix
payload {"full":{"n":1}} {"empty":{},"full":{"n":1}}
items [{"n":1}] [{},{"n":1},{}]

The reproduction exited with status 1 before the fix and 0 afterward. Compiler diagnostics were empty in both runs.

  • Existing tests pass (pnpm test)
  • New/updated tests cover the change
  • Linting and type checks pass (pnpm lint && pnpm typecheck)
  • Full repository build passes
  • Direct ESLint checks on all changed files pass
  • Formatting checks pass

Checklist

  • My code follows the project's coding style
  • I have reviewed my own diff
  • I have added/updated documentation as needed
  • This change does not introduce new warnings

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Compiler drops nested empty objects from variable defaults

1 participant