Skip to content

Make fundamental types part of the language#148

Merged
TheLazyCat00 merged 5 commits into
mainfrom
agent/fundamental-language-types
Jul 27, 2026
Merged

Make fundamental types part of the language#148
TheLazyCat00 merged 5 commits into
mainfrom
agent/fundamental-language-types

Conversation

@TheLazyCat00

@TheLazyCat00 TheLazyCat00 commented Jul 26, 2026

Copy link
Copy Markdown
Member

What changed

  • make Int, Float, Bool, String, and Unit unqualified fundamental language types backed by the compiler's bundled core implementation package
  • keep that implementation package outside source imports, qualification, manifests, and independent versioning while retaining ordinary source declarations, constructors, methods, and primitive-backed layouts
  • replace Void with the real zero-sized singleton type Unit, usable in storage and generic arguments
  • require explicit return Unit(), abort Unit(), and resolve Unit(); handlers always bind their abort value, so no return or error-handling AST node needs a Unit exception
  • make if/elif/guard conditions coercion sites targeting Bool, and counted-loop bounds coercion sites targeting Int
  • keep control flow on semantic types rather than exposing @primitives$ storage
  • update package, dependency, lifetime, operator-coherence, method-lookup, syntax, glossary, examples, and the relevant design stories

Why

The original Void generic-use question exposed two separate inconsistencies. First, an ordinary optional core package could not supply the stable Bool and Int identities already required by control flow. Second, making Void a value while retaining implicit completion would force return-path analysis and AST lowering to recognize one nominal type specially.

The specification now keeps core as a compiler-bundled implementation package, exposes its fundamental types as predeclared semantic names, calls the singleton type Unit, and treats its constructor like any other constructor. if still names Bool because condition checking inherently has an expected type; returns, aborts, and resolves always carry an explicit expression regardless of type.

Validation

  • git diff --check
  • repository forbidden-syntax grep from CLAUDE.md
  • relative Markdown target validation
  • story/spec anchor validation for changed chapters
  • repository-wide contradiction searches for stale Void, ordinary-core, bare-exit, binderless-handler, and fundamental-home-package rules

Summary by CodeRabbit

  • Documentation
    • Formalized fundamental language types (including Unit) and clarified their value/runtime role and the core relationship.
    • Tightened coercion/typing rules for if/elif/guard conditions and counted-loop bounds, including a step-by-step implicit-constructor selection algorithm.
    • Standardized return/abort/resolve behavior around explicit Unit() values and updated ? handler syntax to require binders.
    • Clarified operator placement (home-package behavior) and refined toolchain zane-version/implicit-package wording.
    • Expanded/refreshed design stories (new sections and revised examples) to match the updated Unit and coercion model.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: zane-lang/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 131b4618-a193-4a3b-a7a6-8ecbf6777e01

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The specification now defines fundamental types and coercion sites more explicitly, treats Unit as a concrete value, requires explicit return and abort-path expressions, tightens control-flow and handler syntax, and documents bundled core packaging and related design stories.

Changes

Language model and specification semantics

Layer / File(s) Summary
Fundamental types and coercion
README.md, spec/types.md, spec/syntax.md, spec/glossary.md, spec/operators.md, stories/types.md, stories/control-flow.md
Fundamental types, bundled core behavior, coercion-site resolution, literal conversion, and operator home-package rules are clarified.
Control-flow coercion and handlers
spec/control-flow.md, spec/syntax.md, stories/control-flow.md
Conditions and counted-loop bounds use Bool and Int coercion sites, while abortable handlers require binders and explicit termination expressions.
Unit returns and value semantics
spec/functions.md, spec/error-handling.md, spec/lifetimes.md, spec/memory.md, spec/generics.md, spec/lexical.md, stories/functions.md, stories/error-handling.md
Examples and rules replace Void-style absence with explicit Unit() values across returns, lambdas, abort paths, lifetimes, and memory operations.
Core packaging and documentation references
spec/dependencies.md, spec/packages.md, stories/dependencies.md, README.md
Toolchain and package documentation describe bundled core handling and update specification and design-story listings.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • zane-lang/spec#146: Both changes revise the relationship between bundled core and toolchain versioning.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: promoting fundamental types into the language model.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fundamental-language-types

Comment @coderabbitai help to get the list of available commands.

@TheLazyCat00
TheLazyCat00 marked this pull request as ready for review July 26, 2026 20:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@spec/functions.md`:
- Around line 190-191: Add a blank line immediately after each affected heading:
“3.5 Block-bodied verbs return explicitly” in spec/functions.md (lines 190-191),
“3.6 Handle-typed dynamic reference types have fixed footprint” in
spec/memory.md (lines 298-299), “2.2 Unit abort type” in spec/error-handling.md
(lines 32-33), and “3.4 Unit primary returns are values” in
spec/error-handling.md (lines 109-110); leave the following prose unchanged.

In `@spec/packages.md`:
- Line 17: Update both “No implicit packages” entries in spec/packages.md to
scope the rule to source packages, and explicitly note that the bundled core
package is exempt from the import/manifest requirement and may provide
predeclared fundamental names.

In `@spec/syntax.md`:
- Around line 131-132: Insert a blank line immediately after the new heading in
spec/syntax.md at lines 131-132, and likewise after the heading in spec/types.md
at lines 87-88; make no other content changes.

In `@spec/types.md`:
- Around line 405-414: Update the coercion-site list in the specification to
explicitly include positional arguments of named-constructor calls such as
Vector2.diagonal(...). State that these arguments use the constructor’s declared
parameter types and receive the same implicit conversions as positional
constructor calls, preserving consistent behavior across constructor forms.

In `@stories/error-handling.md`:
- Around line 54-61: Update the earlier error-handling paragraph describing
payload-free failures to remove the stale Void and bare abort contract. Align it
with the Unit-based behavior established in the “The empty door still carries a
value” section: failures carry Unit(), use explicit abort Unit(), and preserve
the corresponding handler binding semantics.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: zane-lang/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c5e6054b-2d6f-49f0-bc95-75631b622058

📥 Commits

Reviewing files that changed from the base of the PR and between d3763ab and dd15490.

📒 Files selected for processing (19)
  • README.md
  • spec/control-flow.md
  • spec/dependencies.md
  • spec/error-handling.md
  • spec/functions.md
  • spec/generics.md
  • spec/glossary.md
  • spec/lexical.md
  • spec/lifetimes.md
  • spec/memory.md
  • spec/operators.md
  • spec/packages.md
  • spec/syntax.md
  • spec/types.md
  • stories/control-flow.md
  • stories/dependencies.md
  • stories/error-handling.md
  • stories/functions.md
  • stories/types.md

Comment thread spec/functions.md
Comment thread spec/packages.md Outdated
Comment thread spec/syntax.md
Comment thread spec/types.md Outdated
Comment thread stories/error-handling.md
@TheLazyCat00

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
spec/types.md (2)

430-438: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Define core constructor visibility at every coercion site.

The resolution algorithm only collects visible implicit constructors, but core is explicitly unavailable to source imports and qualification at Lines 89-90. That leaves literal coercion underspecified: @concepts$NumberInt and similar conversions may not be visible from ordinary source packages despite Line 438 requiring them. State that bundled core implicit constructors are automatically applicable at all coercion sites.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@spec/types.md` around lines 430 - 438, Update the coercion-resolution
specification around the bundled core constructors to state that they are
automatically visible and applicable at every coercion site, despite core being
unavailable to source imports or qualification. Preserve the existing
unique-constructor, ambiguity, and no-constructor outcomes while ensuring
concept-to-fundamental conversions such as `@concepts`$Number to Int are defined
for ordinary source packages.

95-109: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Specify that Unit erasure preserves evaluation.

Because Unit is permitted in fields, arrays, and constructor results, expressions producing Unit may still have side effects. Line 109 should clarify that erasing Unit storage never elides those expressions or changes their evaluation order; otherwise this optimization can change program behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@spec/types.md` around lines 95 - 109, Update the Unit erasure statement in
the Unit type section to explicitly preserve evaluation of expressions producing
Unit and their original evaluation order, including Unit fields, array elements,
and constructor results. Clarify that only runtime storage may be removed; side
effects and observable evaluation must remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@spec/packages.md`:
- Line 17: Update the “No implicit source packages” statements at all referenced
locations to limit the import requirement to access from other source packages.
Clarify that a file’s own package is available through its package declaration
and its members may remain unqualified, while preserving the distinction from
the bundled core implementation.

---

Outside diff comments:
In `@spec/types.md`:
- Around line 430-438: Update the coercion-resolution specification around the
bundled core constructors to state that they are automatically visible and
applicable at every coercion site, despite core being unavailable to source
imports or qualification. Preserve the existing unique-constructor, ambiguity,
and no-constructor outcomes while ensuring concept-to-fundamental conversions
such as `@concepts`$Number to Int are defined for ordinary source packages.
- Around line 95-109: Update the Unit erasure statement in the Unit type section
to explicitly preserve evaluation of expressions producing Unit and their
original evaluation order, including Unit fields, array elements, and
constructor results. Clarify that only runtime storage may be removed; side
effects and observable evaluation must remain unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: zane-lang/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: aa37dba8-b73d-4f1d-b9a7-0d833bdd93b1

📥 Commits

Reviewing files that changed from the base of the PR and between dd15490 and 6a5c41d.

📒 Files selected for processing (7)
  • spec/error-handling.md
  • spec/functions.md
  • spec/memory.md
  • spec/packages.md
  • spec/syntax.md
  • spec/types.md
  • stories/error-handling.md

Comment thread spec/packages.md Outdated
@TheLazyCat00

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@TheLazyCat00 TheLazyCat00 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small detail

Comment thread stories/types.md Outdated

## Unit exposes the package that wasn't one

The question arrived through a generic field. If `Player<T>` carries optional extra settings, `Player<Unit>` is the clean application when there are no settings to carry — but only if the language has a real type with a real value, rather than a return-position marker the type system pretends is a type until someone tries to store it. Making that use legal means `Unit()` exists, occupies no storage, and can sit in a symbol, field, array, or type argument exactly as any other zero-sized value can. Calling that type `Void` no longer fit once it had a value: a void has none, while a unit type has exactly one. The rename says what the model became and leaves `Never` as the natural future name for a type with no values.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain using void. say that Player is the obvious solution, but how do you construct void? this is where we decided to make Void an actual type with constructor Void() which we later renamed to Unit as the more fitting term.

@TheLazyCat00
TheLazyCat00 merged commit c53fdbf into main Jul 27, 2026
1 check passed
@TheLazyCat00
TheLazyCat00 deleted the agent/fundamental-language-types branch July 27, 2026 12:30
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