julia-script / julia-script/silk

language: add canonical nan literals and f32/f64 NAN constants

Open
#109 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement new feature P2 spec-change stdlib
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 nan literal.
  • The literal defaults to f64 and becomes f32 in an f32 context.
  • It denotes the established positive canonical quiet NaN for the selected width.
  • Do not add sign or payload syntax.
  • Declare pub const NAN: f32 = nan and pub const NAN: f64 = nan in 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 nan literal.
  • An unconstrained nan defaults to f64; an f32 context produces f32.
  • f32.NAN and f64.NAN exist 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.
  • SEM0086 continues to reject non-literal constant initializers.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.