Skip to content
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

Got a lot of comptime related errors after update to zig 0.11 #16920

Closed
CGQAQ opened this issue Aug 22, 2023 · 2 comments
Closed

Got a lot of comptime related errors after update to zig 0.11 #16920

CGQAQ opened this issue Aug 22, 2023 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@CGQAQ
Copy link

CGQAQ commented Aug 22, 2023

Zig Version

0.11

Steps to Reproduce and Observed Behavior

compile bun with 0.11.0 or 0.12.0

compiler errors emitted:
0.11.0
0.12.0-dev.157+8e96be008

I think it's related to https://ziglang.org/download/0.11.0/release-notes.html#Forbid-Runtime-Operations-in-comptime-Blocks-

see oven-sh/bun#4233 (comment) for context

An example in these errors:

src/bun.js/api/bun/dns_resolver.zig:1144:31: note: struct requires comptime because of this field
    pending_host_cache_cares: PendingCache = PendingCache.init(),
pub const DNSResolver = struct {
    pending_host_cache_cares: PendingCache = PendingCache.init(),
    //  ^ I don't think this will force DNSResolver to be comptime
};
const PendingCache = bun.HiveArray(GetAddrInfoRequest.PendingCacheKey, 32);
pub fn HiveArray(comptime T: type, comptime capacity: u16) type {
      return struct {
           const Self = @This();
           buffer: [capacity]T = undefined,
           available: std.bit_set.IntegerBitSet(capacity) = std.bit_set.IntegerBitSet(capacity).initFull(),
           pub const size = capacity;

           pub fn init() Self {
               return .{};
           }
     };
}

Expected Behavior

Maybe should've not got these errors? not very sure.

@CGQAQ CGQAQ added the bug Observed behavior contradicts documented or intended behavior label Aug 22, 2023
@CGQAQ
Copy link
Author

CGQAQ commented Aug 22, 2023

caused by

pub const WriterType: type = @typeof(WriteStream(Source.StreamType, undefined));

I accidentally @TypeOfed a type, but the compiler errors is not correct at all IMO

See:
oven-sh/bun#4233 (comment)

@rohlem
Copy link
Contributor

rohlem commented Aug 22, 2023

the compiler errors is not correct at all IMO

Not sure I agree (@TypeOf(type) is perfectly legal), but at least transitively pointing to the member(s), and noting that its type is type, would be helpful.

@Vexu Vexu closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

3 participants