46 lines
1.4 KiB
Markdown
46 lines
1.4 KiB
Markdown
# PR-017 - PBS Const Evaluation and Dependency Rules
|
|
|
|
## Briefing
|
|
|
|
`declare const` validation only checks explicit type and initializer presence. This PR implements constant-expression legality, dependency ordering, cycle detection, and initializer type compatibility.
|
|
|
|
## Motivation
|
|
|
|
Const declarations are part of static semantics and must be deterministic across files.
|
|
|
|
## Target
|
|
|
|
- Const semantic validation layer.
|
|
- Diagnostic coverage for constant expression failures.
|
|
|
|
## Scope
|
|
|
|
- Enforce allowed constant-expression subset.
|
|
- Resolve const dependencies module-wide, independent of source-file order.
|
|
- Reject cycles and unresolved const references.
|
|
- Validate initializer type compatibility with declared const type.
|
|
|
|
## Method
|
|
|
|
- Build const dependency graph from top-level declarations.
|
|
- Evaluate in topological order.
|
|
- Emit stable diagnostics for disallowed forms and graph failures.
|
|
|
|
## Acceptance Criteria
|
|
|
|
- Non-constant initializer forms are rejected deterministically.
|
|
- Cross-file const references resolve independent of source order.
|
|
- Cycles are rejected deterministically.
|
|
- Incompatible const initializer types are rejected.
|
|
|
|
## Tests
|
|
|
|
- Add const-expression positive/negative fixtures.
|
|
- Add cross-file dependency and cycle tests.
|
|
- Add type-compatibility tests.
|
|
|
|
## Non-Goals
|
|
|
|
- General compile-time function execution.
|
|
- Runtime const materialization strategy changes.
|