julia-script / julia-script/silk
syntax: Add an enum declaration
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 0
- Avg merge
- 4h 49m
- Merged PRs (30d)
- 213
Description
Status
Enums are not part of the first stable Silk language. The stable surface uses nominal structs plus
structural unions for closed sum types. This issue tracks a post-stable declaration form with
compiler-owned variant identity and exhaustive matching.
Payload-carrying variants remain separate in #15.
Proposed surface
An ordinary enum has compiler-private discriminants:
enum Direction {
north
south
east
west
}
A represented enum names its storage width and gives every variant an explicit code:
enum Opcode: u8 {
load = 1
store = 2
halt = 255
}
Required behavior
- An ordinary enum is a nominal type whose variant discriminants are not source-visible numeric
values. - A represented enum uses the written integer scalar as its storage representation.
- Every represented variant supplies one explicit, unique code within that scalar's range.
- Matching is exhaustive over the declared variants and reports duplicate, unknown, unreachable,
and missing cases at the source. - Layout, MIR, evaluator, native LLVM, direct Wasm, documentation, and language tooling preserve the
same variant identity and represented codes. - Adding enums must not change the stable semantics of structural unions.
Out of scope
- Payload-carrying variants; see #15.
- Automatic discriminant numbering or smallest-fitting representation selection.
- C union layout; see #16.
- Implicit integer conversions.
Acceptance criteria
- Ordinary and represented enum declarations parse and appear in semantic facts.
- Represented variants reject missing, duplicate, and out-of-range codes.
- Exhaustive matching works for ordinary and represented enums.
- The three execution engines agree on construction, comparison, and matching.
- Public documentation and LSP features present variants deterministically.
- Structural-union behavior remains unchanged.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests; begin by locating the parser and semantic-facts entry points for declarations, then trace the layout, MIR, evaluator, native LLVM, direct Wasm, documentation, and LSP paths it lists. Done means both enum forms satisfy the acceptance criteria, including validation, exhaustive matching, agreement across execution engines, deterministic tooling output, and unchanged structural unions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers, documentation, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100