Skip to content

Introduce SDDL2 Result types#725

Closed
daniellerozenblit wants to merge 1 commit into
facebook:devfrom
daniellerozenblit:export-D103698980
Closed

Introduce SDDL2 Result types#725
daniellerozenblit wants to merge 1 commit into
facebook:devfrom
daniellerozenblit:export-D103698980

Conversation

@daniellerozenblit
Copy link
Copy Markdown
Contributor

Summary:
Replace out-parameter error handling with Result types that bundle values with error codes. This prevents bugs from uninitialized outputs and uses ZL_NODISCARD to catch ignored errors at compile time.

New SDDL2_RESULT_OF(type) macro creates Result structs with accessor macros (SDDL2_isError, SDDL2_error, SDDL2_value) and constructors (SDDL2_success, SDDL2_failure).

API changes:

  • SDDL2_kind_size(), SDDL2_Type_size() now return SDDL2_RESULT_OF(size_t)
  • SDDL2_Stack_pop() now returns SDDL2_RESULT_OF(SDDL2_Value)
  • Internal pop_* helpers now return Result types
  • Added SDDL2_TRY_LET for concise error propagation

Updated all call sites in sddl2.c, sddl2_vm.c, and tests.

Reviewed By: Cyan4973

Differential Revision: D103698980

Summary:
Replace out-parameter error handling with Result types that bundle values with error codes. This prevents bugs from uninitialized outputs and uses ZL_NODISCARD to catch ignored errors at compile time.

New SDDL2_RESULT_OF(type) macro creates Result structs with accessor macros (SDDL2_isError, SDDL2_error, SDDL2_value) and constructors (SDDL2_success, SDDL2_failure).

API changes:
- SDDL2_kind_size(), SDDL2_Type_size() now return SDDL2_RESULT_OF(size_t)
- SDDL2_Stack_pop() now returns SDDL2_RESULT_OF(SDDL2_Value)
- Internal pop_* helpers now return Result types
- Added SDDL2_TRY_LET for concise error propagation

Updated all call sites in sddl2.c, sddl2_vm.c, and tests.

Reviewed By: Cyan4973

Differential Revision: D103698980
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 4, 2026

@daniellerozenblit has exported this pull request. If you are a Meta employee, you can view the originating Diff in D103698980.

@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 5, 2026

This pull request has been merged in 7e19db3.

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.

1 participant