Skip to content

spec-generators: map float to crate::Number; remove FIELD_TYPE_OVERRIDES#104

Merged
lorisleiva merged 1 commit into
mainfrom
loris/spec-gen-float-to-number
Jun 10, 2026
Merged

spec-generators: map float to crate::Number; remove FIELD_TYPE_OVERRIDES#104
lorisleiva merged 1 commit into
mainfrom
loris/spec-gen-float-to-number

Conversation

@lorisleiva

Copy link
Copy Markdown
Member

The sole entry in FIELD_TYPE_OVERRIDESnumberValueNode.number → crate::Number — wasn't really a per-field exception: it was the spec's only float, and the JS generator already maps float → number. Number (a u64|i64|f64 enum with custom serde) is the exact Rust analogue, so the mapping now lives in typeExpr.ts and the whole override surface collapses. attributeBodyLine.ts loses its override lookup (and its nodeKind parameter); nodeStructFragment.ts's Default heuristic drops the opaque-check and moves float out of the Default-able set (Number is Copy, not Default), keeping it in SCALAR_KINDS for Copy.

Generated output is byte-identical: NumberValueNode keeps pub number: Number,, #[derive(Copy)], and the hand-written Number enum is untouched. Tests move alongside the source. No per-field/per-name overrides remain.

lorisleiva commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

Merge activity

  • Jun 10, 2:13 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 10, 2:37 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 10, 2:37 PM UTC: @lorisleiva merged this pull request with Graphite.

@lorisleiva lorisleiva changed the base branch from loris/spec-gen-type-nodes to graphite-base/104 June 10, 2026 14:34
@lorisleiva lorisleiva changed the base branch from graphite-base/104 to main June 10, 2026 14:35
The sole entry in `FIELD_TYPE_OVERRIDES` — `numberValueNode.number → crate::Number` — wasn't really a per-field exception: it was the spec's only `float`, and the JS generator already maps `float → number`. `Number` (a `u64|i64|f64` enum with custom serde) is the exact Rust analogue, so the mapping now lives in `typeExpr.ts` and the whole override surface collapses. `attributeBodyLine.ts` loses its override lookup (and its `nodeKind` parameter); `nodeStructFragment.ts`'s Default heuristic drops the opaque-check and moves `float` out of the Default-able set (`Number` is `Copy`, not `Default`), keeping it in `SCALAR_KINDS` for `Copy`.

Generated output is byte-identical: `NumberValueNode` keeps `pub number: Number,`, `#[derive(Copy)]`, and the hand-written `Number` enum is untouched. Tests move alongside the source. No per-field/per-name overrides remain.
@lorisleiva lorisleiva force-pushed the loris/spec-gen-float-to-number branch from 8da0d38 to e9c113f Compare June 10, 2026 14:36
@lorisleiva lorisleiva merged commit a13d61b into main Jun 10, 2026
4 checks passed
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.

1 participant