Skip to content

phase0/01: recursive Type with closed variant payload - #80

Merged
rieske merged 5 commits into
masterfrom
phase0/01-recursive-type
Jul 27, 2026
Merged

phase0/01: recursive Type with closed variant payload#80
rieske merged 5 commits into
masterfrom
phase0/01-recursive-type

Conversation

@rieske

@rieske rieske commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduce recursive Type with closed variant payload (host finish-for-git transplant, Phase 0 foundation).
  • Follow-up review fixes: empty complete records size 0 in arrays; Round-2/3 residual cleanups.

Stack

Base: master → this PR → phase0/02-type-policy (and rest of stack)

Test plan

  • ctest / package tests green on this tip
  • Review Type foundation APIs in isolation before later stack layers land

rieske added 5 commits July 27, 2026 17:17
Replace the optional-bag / indirection-counter Type model with a
std::variant payload and recursive pointer/array pointees so
pointer-to-function and pointer-to-array no longer bleed nested kinds.

Keep master-facing shims (getAlignment, canAssignFrom, memberCount,
memberAt, isIncompleteStructure, completeStructure) and structure
validation (incomplete members, duplicates, size overflow). Shared
StructBody identity preserves incomplete tag completion for self-ref
structs. Function gains an optional variadic flag (default false).

Unit tests pin the recursive contracts; full ctest suite stays green.
Also ignore /.grok for local plan tracking.
- Natural alignment is size for modeled primitives (long double = 16);
  drop MAX_ALIGN clamp on records.
- completeStructure/completeUnion require an existing record body
  (domain_error on non-record).
- array() rejects incomplete record elements.
- pointer() applies qualifiers via Type(qualifiers) constructor.
- Centralize record/array payload access via private helpers.
- Rename incompleteRecord/getMembers/isIncompleteRecord as canonical
  APIs with structure* shims; rename elementStrideBytes.
- Unit tests pin alignment, complete-on-non-record, and incomplete array.
- Collapse isPointerToBareFunction to isPointerToFunction alias.
- isIncompleteMemberOrElementType includes incomplete records; drop
  redundant double-checks in Type.cpp.
- isIncompleteObjectType uses isIncompleteRecord.
- Fix stale sizeof bag-model comment in SA.
- Unit-test incomplete-record for isIncompleteMemberOrElementType.
Stop clamping array element stride to 1 so sizeof(T[n]) is n*sizeof(T)
for empty complete structs/unions. Add union layout and empty-record
array unit tests.
- Layout complete into temporary members; swap only on success so failed
  re-complete cannot corrupt shared StructBody identity.
- sizeof(type) rejects incomplete object types (void, bare function,
  incomplete records), matching unary sizeof.
- Structure-named complete/incomplete predicates are struct-only; SA uses
  isIncompleteRecord for declarations.
- Unit tests for exception-safe layout and structure-only aliases; functional
  test for sizeof(struct Incomplete); move residual Type tests into namespace.
@mergify

mergify Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 92.585% (-0.9%) from 93.503% — phase0/01-recursive-type into master

@rieske
rieske merged commit 0326590 into master Jul 27, 2026
3 of 4 checks passed
@rieske
rieske deleted the phase0/01-recursive-type branch July 27, 2026 15:47
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.

2 participants