julia-script / julia-script/silk
language: add canonical nan literals and f32/f64 NAN constants
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 48
- Forks
- 0
- Avg merge
- 4h 49m
- Merged PRs (30d)
- 213
Description
Status after the refactor
PR #125 completed the target-dependent half of the original issue: usize and isize now expose MAX, MIN, and BITS, with 32-bit/64-bit and engine coverage. That work is complete and is no longer part of this issue.
The remaining work is a source spelling for canonical floating-point NaN values and ordinary standard-library NAN constants.
Current limitation
Silk's decimal floating-point literal grammar cannot produce an IEEE NaN bit pattern. The literal-only constant-initializer rule (SEM0086) also correctly rejects computed or call-based workarounds such as 0.0 / 0.0 and f64.fromBits(...) in a constant declaration.
Runtime NaN values are already possible, so this is API and language-spelling work rather than a blocker for floating-point execution.
Decided design
- Add a dedicated, contextually typed floating
nanliteral. - The literal defaults to
f64and becomesf32in anf32context. - It denotes the established positive canonical quiet NaN for the selected width.
- Do not add sign or payload syntax.
- Declare
pub const NAN: f32 = nanandpub const NAN: f64 = nanin ordinary standard-library source. - Do not recognize the standard-library declarations by name in the compiler.
- Keep the literal-only constant-initializer rule; do not introduce general constant evaluation.
- Synchronize the authoritative constant specification with the already accepted target-dependent-constant delta while updating it for
nan.
Out of scope
- General constant evaluation.
- User-selected NaN signs or payloads.
- Further target-dependent integer-constant work; PR #125 completed that scope.
Acceptance criteria
- The lexer/parser and semantic model accept a contextually typed
nanliteral. - An unconstrained
nandefaults tof64; anf32context producesf32. -
f32.NANandf64.NANexist as ordinary standard-library constants. - Tests show each constant is not equal to itself.
- Tests assert the positive canonical quiet-NaN bit pattern for each width.
- The evaluator, native LLVM backend, and direct Wasm backend agree.
- The OpenSpec/main specification records the literal and synchronizes the target-dependent constant rules.
-
SEM0086continues to reject non-literal constant initializers.
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
Start with the lexer/parser and semantic model entry points for numeric literals, then trace evaluation through the native LLVM backend and direct Wasm backend. Add the standard-library f32.NAN and f64.NAN declarations and update the OpenSpec/main specification. Done means contextual typing, canonical bit patterns, SEM0086 coverage, and agreement across all listed evaluators and backends.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, wasm
- Domain
- compilers, documentation, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100