Skip to content

fix: make the unsupported-int-width message compile - #41

Merged
lalinsky merged 1 commit into
mainfrom
fix/int-compile-error-message
Sep 5, 2026
Merged

fix: make the unsupported-int-width message compile#41
lalinsky merged 1 commit into
mainfrom
fix/int-compile-error-message

Conversation

@lalinsky

@lalinsky lalinsky commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Fixes #34.

packInt and getIntSize both end their signed and unsigned branches with a @compileError that concatenates a u16 onto a string:

@compileError("Unsupported signed int with " ++ type_info.int.bits ++ "bits");

++ needs indexable operands, so it fails on its own terms before the message is ever produced. Before:

src/int.zig:99:70: error: expected indexable; found 'u16'

After:

src/int.zig:99:9: error: Unsupported signed int with 96 bits

Six sites — both functions, plus both branches of resolveFixedSizeIntHeader. std.fmt.comptimePrint builds the message properly, and the missing space before bits is gone.

Never surfaced because nothing instantiates these with an unsupported width, which is the same reason the defects behind #21, #22 and #23 stayed hidden. It is reachable in practice though: std.Io.Timestamp and std.Io.Duration are both struct { nanoseconds: i96 }, so encoding either one lands exactly here, and a legible error is the difference between "this width is not supported" and a confusing complaint about ++.

Reproduced and verified with packInt(&w, i96, 1).

No changelog entry — the error text is not user-visible until you hit it, and nothing about the supported widths changed. Happy to add one if you would rather it were recorded.

zig build test: 183/183 pass.

packInt and getIntSize both end their signed and unsigned branches with a
@CompileError that concatenates a u16 onto a string:

    @CompileError("Unsupported signed int with " ++ type_info.int.bits ++ "bits");

++ needs indexable operands, so this fails on its own terms before the message
is produced. Asking for an unsupported width gave

    error: expected indexable; found 'u16'

rather than the intended text. Six sites, across both functions and both
resolveFixedSizeIntHeader branches.

std.fmt.comptimePrint builds it properly, and the missing space before "bits"
is gone. packInt(&w, i96, 1) now reports

    error: Unsupported signed int with 96 bits

Never surfaced because nothing instantiates these with an unsupported width,
the same reason the defects behind #21, #22 and #23 stayed hidden. The message
is reachable in practice, though: std.Io.Timestamp and std.Io.Duration are
both struct { nanoseconds: i96 }, so encoding either lands here.
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 6d864985-8d20-4d07-a522-e5824a033f7b

📥 Commits

Reviewing files that changed from the base of the PR and between 0417cac and 0f66235.

📒 Files selected for processing (1)
  • src/int.zig

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lalinsky
lalinsky merged commit db7dc86 into main Sep 5, 2026
3 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.

@compileError for unsupported int widths fails to compile itself

1 participant