Numeric conversion spec - #25
Open
ESRogs wants to merge 10 commits into
Open
Conversation
ESRogs
force-pushed
the
conversion-spec
branch
7 times, most recently
from
August 13, 2026 21:00
3c49461 to
f07d9db
Compare
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
force-pushed
the
conversion-spec
branch
3 times, most recently
from
August 14, 2026 16:42
43eb2e4 to
835f938
Compare
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
commented
Aug 14, 2026
ESRogs
force-pushed
the
conversion-spec
branch
4 times, most recently
from
August 14, 2026 21:07
baedc47 to
5638336
Compare
ESRogs
commented
Aug 14, 2026
|
|
||
| /// Ops whose names contain `_to_` but do not convert between two number types. | ||
| /// Listing one here is how it is excused from | ||
| /// `assertNothingConversionShapedEscapes`. |
Owner
Author
There was a problem hiding this comment.
Why don't we put it next to that assert then?
ESRogs
force-pushed
the
conversion-spec
branch
12 times, most recently
from
August 18, 2026 21:40
814bd0a to
e490014
Compare
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The integer-to-Dec branch reads the source's signedness, which is what the replaced table's target-signedness field held for those two ops. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The range bounds are computed where they are emitted, which is only for destinations narrower than 64 bits; the replaced table stored unread placeholders for the two 64-bit entries. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The 214 arms named a helper and its type arguments per op. A router picks both from the spec instead, so the switch keeps only the op names the lint requires. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Thirteen `*_to_str` ops leave the not-a-conversion list, so rule 0 now accounts for them by what they are rather than by exclusion. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`numericParseSpec` moves beside the parse it now reads, since `LowLevel` imports nothing and importing the spec there would close a cycle. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ESRogs
force-pushed
the
conversion-spec
branch
from
August 19, 2026 22:12
e490014 to
40f980a
Compare
ESRogs
commented
Aug 19, 2026
| } | ||
|
|
||
| /// Split a name such as `dec_to_u64_trunc` into its three parts. Returns null | ||
| /// unless both ends are a `NumType`, which is what separates a conversion from |
Owner
Author
There was a problem hiding this comment.
Two options
/// Split a name into `source`, `"_to_"`, and `destination`. If either `source` or `destination` is not a `NumType`, it returns null.
or:
/// Match a name against `"${source}_to_${destination}`. If either `source` or `destination` is not a `NumType`, it returns null.
Though not sure if that's the right way to describe the template in zig. Not sure if fixable, or we should just go with the first option.
Owner
Author
There was a problem hiding this comment.
Oh, maybe we should use src and dst rather than source and destination.
Owner
Author
There was a problem hiding this comment.
Also, is "name" too generic? Like what kind of name is it? I think that's why I was suggesting the example. Also "parse" is pretty generic too.
ESRogs
commented
Aug 19, 2026
| /// Split a name such as `dec_to_str` into a number type and a direction. | ||
| /// Returns null unless the half beside `str` is a `NumType`, which is what | ||
| /// separates `dec_to_str` from `num_to_str`. | ||
| fn parseString(name: []const u8) ?StringConversion { |
Owner
Author
There was a problem hiding this comment.
parseString does not at all sound like it means "parse the name of a function that converts a numtype to a string."
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebuild of roc-lang#10736 against
conversion-spec-design.md, split into small commits. Iteration happens here; roc-lang#10736 gets reset to this once it settles.The spec is the triple
(src, dst, mode)parsed from each op name once, at comptime. There is no shared grouping enum: consumers route on the source and destination classes, then switch on the mode, splitting further where a handler assumes more than the spec says.Five comptime rules run over the whole enum, so any build of the compiler checks them:
Each rule was verified by breaking it and confirming the build fails naming the op.
All four consumers derive from the spec. The LLVM backend routes on it; dev, wasm, and the interpreter keep the op prongs
ci/zig_lints.zigrequires and drop the facts they restated. Three of those commits exist because a table did not merely repeat an op name but misnamed a field.The last three commits extend the spec to a number's text and are removable as a unit.
Verification of the LLVM dispatch swap. No CLI flag emits LLVM IR, so
test/fx/runtime_dec_to_int_wrap_widths.rocwas compiled at--opt=speedon the commit before and after: byte-identical binaries, same SHA-256. That fixture drives all ten Dec-to-integer widths plus truncation and past-I64 wrapping.Suites at
f07d9db39b, compared againstroc-lang/rocmain7f9b644e33.run-check-*passes. Eval on the interpreter, dev, and wasm executors is 1930/1930. Under--llvm23 tests fail, and underrun-test-cli9 fail; both sets carry the same names on the baseline, so neither belongs to this branch. The--llvmbaseline additionally hangs 10 tests that pass here, at a count that varies between runs on this machine, so that difference is not attributable either way.