Skip to content

Settle the constant type as one shape, not two - #417

Draft
Firehed wants to merge 1 commit into
mainfrom
docs/constant-representation
Draft

Settle the constant type as one shape, not two#417
Firehed wants to merge 1 commit into
mainfrom
docs/constant-representation

Conversation

@Firehed

@Firehed Firehed commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Without this, S3.8b would have had to decide in-flight whether a global constant gets its own metadata type, its own name type, and its own resolved wrapper. Three near-copies of types that already exist is the duplication this rework removes, so the decision is recorded before the slice that would otherwise make it under pressure.

Docs only. No code changes.

The decision

A constant is one type whether or not a class declares it:

  • Domain\ConstantInfo serves both. declaringClass becomes ?ClassName, and its absence is what makes a constant global.
  • visibility and isFinal stay non-nullable. A global constant is mechanically public and final — a redeclared const is a fatal and a repeated define() is a no-op — so those fields carry the true value, not a placeholder.
  • format() branches on the declaring class alone (public const X versus const X).
  • Domain\ConstantName holds either a member name or an FQN, so the ConstantName that RFC 1 §5.3 calls for needs no second type. This closes the collision the manifest previously flagged as decide-before-S3.8b.
  • A global constant is not a ResolvedMember. That interface means reached through a class, via -> or ::, which a global constant has no path for. So ConstantInfo implements ResolvedSymbol itself rather than gaining a fifth thin wrapper — also a down payment on the wrapper collapse in Decide whether Domain *Info and Resolution Resolved* should become one set of objects #416.

Net new types needed to represent global constants: zero.

Where it lands

  • 0002-execution-plan.md §5.3 (the name-type model) carries the decision.
  • build-manifest.md's note under the JIT name-type bullet is rewritten from posing the question to recording the answer.

Plan step: 0002 §5.3, feeding S3.8b's acceptance. RFC section: RFC 1 §5.1 (concrete return types per kind), §5.3.

Checklist

  • The ConstantName collision the manifest deferred is resolved, not restated
  • The nullable field is justified against the project's no-nullable rule, in the doc
  • Manifest note rewritten rather than appended to (docs rule)
  • Slice table untouched, so SymbolCoverageGridTest's registry parse is unaffected

Candidate closes (pending review verification): none.

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.62%. Comparing base (d101d21) to head (39a6503).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #417   +/-   ##
=========================================
  Coverage     98.62%   98.62%           
  Complexity     1814     1814           
=========================================
  Files           128      128           
  Lines          4571     4571           
=========================================
  Hits           4508     4508           
  Misses           63       63           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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