Skip to content

feat(types): array types and sizeof - #68

Merged
rieske merged 7 commits into
masterfrom
feature/recursive-type-sizeof
Jul 24, 2026
Merged

feat(types): array types and sizeof#68
rieske merged 7 commits into
masterfrom
feature/recursive-type-sizeof

Conversation

@rieske

@rieske rieske commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • type::array(T, n) with recursive element type and getSize().
  • Sized array declarators type-check; array access still not implemented.
  • sizeof expr and sizeof(type) for primitives and pointers.
  • Functional SizeofTest; catalog no longer expects sized arrays to fail early.

Review follow-ups

  • Reject array size overflow (element_size * count / count > INT_MAX).
  • Reject array of incomplete type (void a[3], void parameters).
  • isArray() false for pointer-to-array.
  • Diagnose sizeof(void).
  • Extra functional coverage (array-of-pointers, sizeof as bound, multi-dim, error paths) to address Coveralls regression.

Known limitations (intentional this slice)

  • Stack storage: locals still get one machine-word frame slot. Multi-element arrays are not multi-word allocated yet.
  • Array access / indexing IR: not implemented.

Stack

PR 5/6 — base is master. Tip is #69.

Test plan

  • Full local ctest
  • SizeofTest + Type unit tests
  • CI green

@mergify

mergify Bot commented Jul 24, 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

@rieske
rieske force-pushed the feature/switch-case branch from 4e72ebc to 664d527 Compare July 24, 2026 07:12
@rieske
rieske force-pushed the feature/recursive-type-sizeof branch from df5b3ef to fa34efb Compare July 24, 2026 07:12
@coveralls

coveralls commented Jul 24, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 92.637% (+0.2%) from 92.455% — feature/recursive-type-sizeof into master

@rieske
rieske force-pushed the feature/recursive-type-sizeof branch from fa34efb to adb305e Compare July 24, 2026 07:18
@rieske
rieske force-pushed the feature/switch-case branch from 664d527 to 608b6e1 Compare July 24, 2026 07:18
@rieske
rieske force-pushed the feature/recursive-type-sizeof branch from adb305e to c27b7a9 Compare July 24, 2026 07:27
@rieske
rieske force-pushed the feature/switch-case branch from 608b6e1 to 015d412 Compare July 24, 2026 07:27
Base automatically changed from feature/switch-case to master July 24, 2026 07:33
rieske added 4 commits July 24, 2026 10:33
Add type::array as a recursive element type with size, wire sized array
declarators, and implement sizeof (expr) / sizeof(type) including
simple pointer type names. Functional tests cover sizeof and array
declaration sizing without requiring array element access.
Fold array bounds during semantic analysis and report invalid sizes via
semanticError instead of throwing from getFundamentalType. Frame layout
for multi-element arrays remains one slot per local (sizeof-only safe).
Sized array types are established in semantic analysis; the declarator
visitor no longer throws. Update the unit expectation accordingly.
Replace the inline type_name+abstract lambda with a free function to match
other CSNB creators, and note that casts remain unimplemented while
sizeof(type) works.
@rieske
rieske force-pushed the feature/recursive-type-sizeof branch from c27b7a9 to b9f786c Compare July 24, 2026 07:34
rieske added 3 commits July 24, 2026 10:56
Reject array size overflow and incomplete element types, treat
pointer-to-array as pointer-only, diagnose sizeof(void), and add
functional/unit coverage for those paths (also restores Sizeof surface).
Diagnose sizeof of function designators (not just sizeof(type)), and
keep FunctionDeclarator recovery when FormalArgument already rejected
an incomplete array parameter type.
Treat only bare function types as incomplete for sizeof and array
elements; allow pointer-to-function. Print nested array dimensions
outside-in. Add regression coverage for both.
@rieske
rieske merged commit 93de9fe into master Jul 24, 2026
4 checks passed
@rieske
rieske deleted the feature/recursive-type-sizeof branch July 24, 2026 08:36
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