Skip to content

fix(float): a float's text is read by strtod, not by Float from - #237

Merged
jonruttan merged 2 commits into
mainfrom
fix/float-strtod
Nov 18, 2026
Merged

jonruttan merged 2 commits into
mainfrom
fix/float-strtod

Conversation

@jonruttan

Copy link
Copy Markdown
Owner

On x-lang main, every specs @ x-lang main job fails with Float from: not convertible to FLOAT. That includes x-python main itself, rerun today. The cause is x-lang #1322 (eac54454, in the untagged 0.56.0): Float from now reads a string as x source. 1e3, 1., .5, inf and nan are no longer floats to it.

x-python's callers have already checked the text against Python's own grammar before converting: the tokenizer for literals, and %py-float-str-ok? for float('...'). So the C library's reading is the right one.

  • python-strtod (python/types.x) wraps x/num/float's exported str->float, which is strtod on v0.55.0 and on main alike. It is taken by a selective import inside a call, the way %py-libm-fn takes libm-fn.
  • Float literals, imaginary literals, float('...') (including inf/nan) and round()'s rebuilt results go through it. No Float from on a string is left.

Verified, full suite:

  • x-lang main (a8c71419, built locally): 129 spec files, 1,198 tests, 0 failed.
  • v0.55.0: 129 spec files, 1,198 tests, 0 failed.

This unblocks the x-lang main jobs on #236 too.

🤖 Generated with Claude Code

jonruttan and others added 2 commits November 18, 2026 04:15
x-lang #1322 made `Float from` read a string as x source: 1e3, 1., .5,
inf and nan are no longer floats there, and every Python float literal
and float() of them failed on x-lang main with "Float from: not
convertible to FLOAT".  Each caller has already checked the text against
Python's grammar, so it wants the C library's reading: python-strtod
(python/types.x) takes x/num/float's str->float, exported on v0.55.0 and
on main alike, through a selective import inside a call as %py-libm-fn
does.  Float literals, imaginary literals, float('...') and round()'s
rebuilt results go through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
python/types.x loads before python/core.x imports the tower, so its
import of x/num/float loaded float on the bare dialect, and the source
boot (`x -l python`, tests/boot.sh) ran out of memory at 12 GB.  The
suite's harness has the whole tower loaded first and never saw it.
runtime-num.x loads after the tower and ahead of every caller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonruttan
jonruttan merged commit c45b8c7 into main Nov 18, 2026
12 checks passed
@jonruttan
jonruttan deleted the fix/float-strtod branch November 18, 2026 19:40
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