Skip to content

Support constant-backed type aliases in variable declarations (safe + unsafe) with explicit invalid-case errors#104

Merged
DanexCodr merged 3 commits into
mainfrom
copilot/add-type-alias-support
Apr 15, 2026
Merged

Support constant-backed type aliases in variable declarations (safe + unsafe) with explicit invalid-case errors#104
DanexCodr merged 3 commits into
mainfrom
copilot/add-type-alias-support

Conversation

Copilot AI commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

This change adds first-class support for using ALL_CAPS constants that hold type values as variable type aliases (e.g. n: BYTE = 3 after BYTE: type = u8). It also hardens invalid alias paths with explicit ProgramErrors for non-constant alias names and non-type alias values.

  • Type alias resolution in variable declarations

    • Variable declaration type checking now resolves declared type names through in-scope alias bindings (locals/slots) when present.
    • Resolved aliases are used for validation and union wrapping, preserving existing behavior for non-alias type names.
  • Explicit alias validity rules and error messages

    • If an alias binding is found but the name is not ALL_CAPS, a clear ProgramError is raised with constant-declaration guidance.
    • If an ALL_CAPS alias exists but does not hold a type value, a clear ProgramError is raised with expected declaration format.
  • Type-literal parsing support for unsafe keywords

    • Expression parsing now treats unsafe numeric type keywords (i8/i16/i32/i64/u8/u16/u32/u64/f32/f64) as type literals, enabling declarations like BYTE: type = u8.
  • Demo coverage updates

    • Added a new type-alias demo set:
      • valid alias usage,
      • invalid non-constant alias usage,
      • invalid non-type alias value usage.
    • Extended valid demo coverage to safe aliases: int, float, text, bool.
BYTE: type = u8
WHOLE: type = int
WORD: type = text

n: BYTE = 3
a: WHOLE = 42
c: WORD = "ok"

Copilot AI and others added 3 commits April 14, 2026 15:26
Agent-Logs-Url: https://github.com/DanexCodr/Coderive/sessions/8fc0bd2a-1ab9-48ec-8014-e759c71a9b63

Co-authored-by: DanexCodr <216312766+DanexCodr@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DanexCodr/Coderive/sessions/8fc0bd2a-1ab9-48ec-8014-e759c71a9b63

Co-authored-by: DanexCodr <216312766+DanexCodr@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DanexCodr/Coderive/sessions/fd794ed8-8652-40d0-8ca4-9eaa53e5eba2

Co-authored-by: DanexCodr <216312766+DanexCodr@users.noreply.github.com>
@DanexCodr DanexCodr marked this pull request as ready for review April 15, 2026 02:33
@DanexCodr DanexCodr merged commit 9a29af1 into main Apr 15, 2026
@DanexCodr DanexCodr deleted the copilot/add-type-alias-support branch April 15, 2026 02:33
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