Skip to content

formatIntValue doesn't take comptime integer #1780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
daurnimator opened this issue Nov 24, 2018 · 0 comments
Closed

formatIntValue doesn't take comptime integer #1780

daurnimator opened this issue Nov 24, 2018 · 0 comments
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@daurnimator
Copy link
Contributor

formatIntValue doesn't take a comptime integer. It fails with zig/std/fmt/index.zig:683:23: error: type 'comptime_int' does not support field access

const std = @import("std");
const Buffer = std.Buffer;
const mem = std.mem;
const assert = std.debug.assert;

test "can format a comptime int" {
    const value:comptime_int = 123456789123456789;

    var buf = try Buffer.init(std.debug.global_allocator, "");
    try std.fmt.formatIntValue(value, "", &buf, @typeOf(Buffer.append).ReturnType.ErrorSet, Buffer.append);
    assert(mem.eql(u8, buf.toSlice(), "123456789123456789"));
}
/usr/lib/zig/std/fmt/index.zig:683:23: error: type 'comptime_int' does not support field access
    if (@typeOf(value).is_signed) {
                      ^
/usr/lib/zig/std/fmt/index.zig:320:21: note: called from here
    return formatInt(value, radix, uppercase, width, context, Errors, output);
                    ^
test.zig:10:31: note: called from here
    try std.fmt.formatIntValue(value, "", &buf, @typeOf(Buffer.append).ReturnType.ErrorSet, Buffer.append);
                              ^
@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library. labels Nov 24, 2018
@andrewrk andrewrk added this to the 0.5.0 milestone Nov 24, 2018
@andrewrk andrewrk modified the milestones: 0.5.0, 0.4.0 Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

2 participants