Add new numeric constants for octal and binary to chialisp - #402
Merged
Merged
Conversation
prozacchiwawa
marked this pull request as ready for review
March 18, 2026 19:14
…ensure bytes are scanned right to left when regenerating bit constants
…xed that. ensured tests are exercised on precisely comparable amounts of padding
…prefix 0s for decimal constants so modern mirrors the way classic allows multiply padded decimal constants
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Quexington
approved these changes
Mar 19, 2026
Quexington
left a comment
Contributor
There was a problem hiding this comment.
I won't pretend to understand the semantics of this change but I approve it conceptually.
aqk
approved these changes
Mar 23, 2026
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.

This will add new octal and binary constants to chialisp compilation. Since the data representation of clvm values uses virtually every string as some kind of valid value, a new
*bitconst*include is provided to enable interpretation as octal and binary.The rule for these bit constants is that if a completely unnecessary zero is used as left padding that appears in a new byte, then the constant has that left zero byte.
In modern, it's enabled by the sigil
*standard-cl-nc25*, in classic by*bitconst*(this is the first sigil affecting classic).Since the first 0 is required, 0o0 and 0b0 are () not 0x00.
0b00 and 0o00 are 0x00.
Consider the octal constant 0o377, which is 0b11111111, this is -1 or 0xff.
If you add a zero to 0o377, 0o0377, then this is 0x00ff. 0b011111111 is also 0x00ff.
Note
Medium Risk
Touches core parsing/printing paths for both classic IR and the modern compiler, so subtle parsing or round-tripping regressions are possible even though the feature is gated behind dialect/include flags.
Overview
Adds opt-in binary (
0b...) and octal (0o...) numeric literals that compile to byte-atoms with defined left-padding semantics.This introduces a
NEW_BIT_CONSTANTSlanguage flag and threads it through classic tooling (read_ir/IRReader,assemble/disassemble, and stage-2 operators) and the modern compiler parser (parse_sexp_flags) so dialect detection can re-parse with the correct numeric rules. New dialect sigils*standard-cl-nc25*(modern) and*bitconst*(classic) enable the behavior, and a dedicated test suite (tests/classic/bitconst.rs) validates parsing, disassembly round-trips, and fuzzes padding edge-cases.Written by Cursor Bugbot for commit e04b8c9. This will update automatically on new commits. Configure here.