Skip to content

chore: Unify eqlCaseInsensitiveASCIIPlaceholders of the world - #25286

Closed
markovejnovic wants to merge 2 commits into
mainfrom
user/markovejnovic/eqlCaseInsensitiveASCII-unification
Closed

markovejnovic wants to merge 2 commits into
mainfrom
user/markovejnovic/eqlCaseInsensitiveASCII-unification

Conversation

@markovejnovic

Copy link
Copy Markdown
Contributor

What does this PR do?

Removes redundant eqlCaseInsensitiveASCII variants.

How did you verify your code works?

CI.

@robobun

robobun commented Dec 1, 2025 •

Copy link
Copy Markdown
Collaborator

@coderabbitai

coderabbitai Bot commented Dec 1, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Consolidates case-insensitive ASCII comparison logic by adding a single eqlCaseInsensitiveASCII(a, b) implementation and updating call sites to remove previous comptime/boolean length-flag variants, replacing multiple length-aware equality helpers with the unified API across the codebase.

Changes

Cohort / File(s) Summary
Core string implementation
src/string/immutable.zig, src/string.zig
Adds pub inline fn eqlCaseInsensitiveASCII(a, b) and removes prior variants (eqlCaseInsensitiveASCII(..., comptime check_len), IgnoreLength, ICheckLength); updates eqlCaseInsensitiveT and callers to use the new function.
Bun core & JS bindings
src/bun.zig, src/bun.js/api/crypto/EVP.zig, src/bun.js/node/path.zig, src/bun.js/uuid.zig, src/bun.js/api/bun/socket/SocketAddress.zig
Replaces length-flagged comparisons with eqlCaseInsensitiveASCII for environment vars, crypto lookups, path/name comparisons, UUID namespace checks, and socket address literal matching.
CLI
src/cli/create_command.zig, src/cli/pack_command.zig, src/cli/publish_command.zig
Updates header/name/filename and filename-special checks to call the unified comparison function (removed explicit flags).
HTTP & networking
src/deps/picohttp.zig, src/http.zig, src/http/Headers.zig, src/http/websocket_client/WebSocketUpgradeClient.zig, src/url.zig
Switches header, redirect origin, multipart key, and WebSocket header/value comparisons to the two-argument eqlCaseInsensitiveASCII form.
CSS parsing (core, rules, properties, selectors, values)
src/css/css_parser.zig, src/css/media_query.zig, src/css/targets.zig, src/css/properties/*, src/css/rules/*, src/css/selectors/parser.zig, src/css/values/*
Replaces many length-aware case-insensitive checks with eqlCaseInsensitiveASCII across ident/function/keyword/unit/pseudo-class parsing and related branches.
CSS properties (specific files)
src/css/properties/animation.zig, src/css/properties/background.zig, src/css/properties/custom.zig, src/css/properties/font.zig, src/css/properties/generate_properties.ts, src/css/properties/grid.zig, src/css/properties/transform.zig, src/css/properties/css_modules.zig
Updates keyword/enum matching to use the unified comparison; minor non-functional edit in generate_properties.ts.
CSS values (specific files)
src/css/values/angle.zig, src/css/values/color.zig, src/css/values/easing.zig, src/css/values/gradient.zig, src/css/values/ident.zig, src/css/values/image.zig, src/css/values/length.zig, src/css/values/resolution.zig, src/css/values/syntax.zig, src/css/values/time.zig
Replaces unit/keyword checks with eqlCaseInsensitiveASCII across value parsing.
Rules & selectors
src/css/rules/container.zig, src/css/rules/font_face.zig, src/css/rules/font_palette_values.zig, src/css/rules/keyframes.zig, src/css/rules/property.zig, src/css/rules/supports.zig
Replaces length-aware comparisons with the unified ASCII-insensitive check for rule/keyword parsing.
Install / repo / resolver / path utils
src/install/repository.zig, src/resolver/resolve_path.zig, src/which.zig
Changes gitconfig key matching, Windows-root / path comparisons, and extension checks to use eqlCaseInsensitiveASCII.
Options / output / SQL / env / other utilities
src/options.zig, src/output.zig, src/sql/postgres/DataCell.zig, src/env_var.zig, src/which.zig
Replaces loader-name, logger visibility, SQL NULL/Infinity checks, environment boolean parsing, and extension comparisons to call the new API.

Possibly related PRs

Suggested reviewers

  • pfgithub
  • nektro
  • dylan-conway
  • taylordotfish

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: unifying multiple variants of eqlCaseInsensitiveASCII functions into a single implementation.
Description check ✅ Passed The description follows the template with both required sections completed. It explains what the PR does (removes redundant variants) and how verification was performed (CI).

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1bad8a4 and 59ff3d6.

📒 Files selected for processing (5)
  • src/bun.js/api/bun/socket/SocketAddress.zig (1 hunks)
  • src/css/css_parser.zig (13 hunks)
  • src/env_var.zig (1 hunks)
  • src/http.zig (5 hunks)
  • src/string/immutable.zig (3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
src/**/*.{cpp,zig}

📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)

src/**/*.{cpp,zig}: Use bun bd or bun run build:debug to build debug versions for C++ and Zig source files; creates debug build at ./build/debug/bun-debug
Run tests using bun bd test <test-file> with the debug build; never use bun test directly as it will not include your changes
Execute files using bun bd <file> <...args>; never use bun <file> directly as it will not include your changes
Enable debug logs for specific scopes using BUN_DEBUG_$(SCOPE)=1 environment variable
Code generation happens automatically as part of the build process; no manual code generation commands are required

Files:

  • src/http.zig
  • src/env_var.zig
  • src/bun.js/api/bun/socket/SocketAddress.zig
  • src/css/css_parser.zig
  • src/string/immutable.zig
src/**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)

Use bun.Output.scoped(.${SCOPE}, .hidden) for creating debug logs in Zig code

Implement core functionality in Zig, typically in its own directory in src/

src/**/*.zig: Zig source code should be organized in src/*.zig for core runtime, JavaScript bindings, and package manager
In Zig code, be careful with allocators and use defer for cleanup to manage memory properly
Use BUN_DEBUG_QUIET_LOGS=1 to disable debug logging, or BUN_DEBUG_<scopeName>=1 to enable specific Output.scoped calls in debug builds
Run bun run zig:check-all to compile the Zig code on all platforms when making platform-specific changes

src/**/*.zig: Private fields in Zig are fully supported using the # prefix: struct { #foo: u32 };
Use decl literals in Zig for declaration initialization: const decl: Decl = .{ .binding = 0, .value = 0 };
Prefer @import at the bottom of the file (auto formatter will move them automatically)

Files:

  • src/http.zig
  • src/env_var.zig
  • src/bun.js/api/bun/socket/SocketAddress.zig
  • src/css/css_parser.zig
  • src/string/immutable.zig
**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/zig-javascriptcore-classes.mdc)

**/*.zig: Expose generated bindings in Zig structs using pub const js = JSC.Codegen.JS<ClassName> with trait conversion methods: toJS, fromJS, and fromJSDirect
Use consistent parameter name globalObject instead of ctx in Zig constructor and method implementations
Use bun.JSError!JSValue return type for Zig methods and constructors to enable proper error handling and exception propagation
Implement resource cleanup using deinit() method that releases resources, followed by finalize() called by the GC that invokes deinit() and frees the pointer
Use JSC.markBinding(@src()) in finalize methods for debugging purposes before calling deinit()
For methods returning cached properties in Zig, declare external C++ functions using extern fn and callconv(JSC.conv) calling convention
Implement getter functions with naming pattern get<PropertyName> in Zig that accept this and globalObject parameters and return JSC.JSValue
Access JavaScript CallFrame arguments using callFrame.argument(i), check argument count with callFrame.argumentCount(), and get this with callFrame.thisValue()
For reference-counted objects, use .deref() in finalize instead of destroy() to release references to other JS objects

Files:

  • src/http.zig
  • src/env_var.zig
  • src/bun.js/api/bun/socket/SocketAddress.zig
  • src/css/css_parser.zig
  • src/string/immutable.zig
src/**/*.{ts,zig,cpp}

📄 CodeRabbit inference engine (CLAUDE.md)

Always use absolute paths in file operations

Files:

  • src/http.zig
  • src/env_var.zig
  • src/bun.js/api/bun/socket/SocketAddress.zig
  • src/css/css_parser.zig
  • src/string/immutable.zig
src/**/*.{ts,zig}

📄 CodeRabbit inference engine (CLAUDE.md)

Avoid shell commands in code - don't use find or grep; use Bun's Glob and built-in tools instead

Files:

  • src/http.zig
  • src/env_var.zig
  • src/bun.js/api/bun/socket/SocketAddress.zig
  • src/css/css_parser.zig
  • src/string/immutable.zig
🧠 Learnings (21)
📓 Common learnings
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 24423
File: test/js/node/path/browserify.test.js:472-475
Timestamp: 2025-11-07T17:28:58.045Z
Learning: markovejnovic prefers functional programming patterns (e.g., using reduce) over imperative loops and does not want style-based readability suggestions unless there's a concrete technical reason beyond personal preference.
<!--
📚 Learning: 2025-10-16T02:17:35.237Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/analytics.zig:15-21
Timestamp: 2025-10-16T02:17:35.237Z
Learning: In src/analytics.zig and similar files using bun.EnvVar boolean environment variables: the new EnvVar API for boolean flags (e.g., bun.EnvVar.do_not_track.get(), bun.EnvVar.ci.get()) is designed to parse and return boolean values from environment variables, not just check for their presence. This is an intentional design change from the previous presence-based checks using bun.getenvZ().

Applied to files:

  • src/http.zig
  • src/env_var.zig
  • src/css/css_parser.zig
📚 Learning: 2025-11-11T22:55:08.547Z
Learnt from: pfgithub
Repo: oven-sh/bun PR: 24571
File: src/css/values/url.zig:97-116
Timestamp: 2025-11-11T22:55:08.547Z
Learning: In Zig 0.15, the standard library module `std.io` was renamed to `std.Io` (with capital I). Code using `std.Io.Writer.Allocating` and similar types is correct for Zig 0.15+.

Applied to files:

  • src/http.zig
📚 Learning: 2025-10-17T20:50:58.644Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23755
File: src/bun.js/api/bun/socket/Handlers.zig:154-159
Timestamp: 2025-10-17T20:50:58.644Z
Learning: In Bun socket configuration error messages (src/bun.js/api/bun/socket/Handlers.zig), use the user-facing JavaScript names "data" and "drain" instead of internal field names "onData" and "onWritable", as these are the names users see in the API according to SocketConfig.bindv2.ts.

Applied to files:

  • src/http.zig
  • src/bun.js/api/bun/socket/SocketAddress.zig
📚 Learning: 2025-09-12T18:16:50.754Z
Learnt from: RiskyMH
Repo: oven-sh/bun PR: 22606
File: src/glob/GlobWalker.zig:449-452
Timestamp: 2025-09-12T18:16:50.754Z
Learning: For Bun codebase: prefer using `std.fs.path.sep` over manual platform separator detection, and use `bun.strings.lastIndexOfChar` instead of `std.mem.lastIndexOfScalar` for string operations.

Applied to files:

  • src/http.zig
  • src/bun.js/api/bun/socket/SocketAddress.zig
📚 Learning: 2025-10-16T21:24:52.779Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/crash_handler.zig:1415-1423
Timestamp: 2025-10-16T21:24:52.779Z
Learning: When a boolean EnvVar in src/envvars.zig is defined with a default value (e.g., `.default = false`), the `get()` method returns `bool` instead of `?bool`. This means you cannot distinguish between "environment variable not set" and "environment variable explicitly set to the default value". For opt-out scenarios where detection of explicit setting is needed (like `BUN_ENABLE_CRASH_REPORTING` on platforms where crash reporting defaults to enabled), either: (1) don't provide a default value so `get()` returns `?bool`, or (2) use the returned boolean directly instead of only checking if it's true.

Applied to files:

  • src/env_var.zig
📚 Learning: 2025-10-18T20:50:47.750Z
Learnt from: theshadow27
Repo: oven-sh/bun PR: 23798
File: src/bun.js/telemetry.zig:366-373
Timestamp: 2025-10-18T20:50:47.750Z
Learning: In Bun's Zig codebase (src/bun.js/bindings/JSValue.zig), the JSValue enum uses `.null` (not `.js_null`) for JavaScript's null value. Only `js_undefined` has the `js_` prefix to avoid collision with Zig's built-in `undefined` keyword. The correct enum fields are: `js_undefined`, `null`, `true`, `false`, and `zero`.

Applied to files:

  • src/env_var.zig
  • src/bun.js/api/bun/socket/SocketAddress.zig
📚 Learning: 2025-10-15T22:03:50.832Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/envvars.zig:135-144
Timestamp: 2025-10-15T22:03:50.832Z
Learning: In src/envvars.zig, the boolean feature flag cache uses a single atomic enum and should remain monotonic. Only the string cache (which uses two atomics: ptr and len) requires acquire/release ordering to prevent torn reads.

Applied to files:

  • src/env_var.zig
📚 Learning: 2025-10-16T17:32:03.074Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/install/PackageManager/PackageManagerOptions.zig:187-193
Timestamp: 2025-10-16T17:32:03.074Z
Learning: In Bun's codebase (particularly in files like src/install/PackageManager/PackageManagerOptions.zig), mixing bun.EnvVar.*.get() and bun.EnvVar.*.platformGet() for environment variable lookups is intentional and safe. The code is protected by compile-time platform checks (Environment.isWindows, etc.), and compilation will fail if the wrong function is used on the wrong platform. This pattern should not be flagged as a consistency issue.

Applied to files:

  • src/env_var.zig
📚 Learning: 2025-11-12T07:15:00.763Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 24631
File: src/install/resolution.zig:375-376
Timestamp: 2025-11-12T07:15:00.763Z
Learning: In src/install/resolution.zig, the eql() function intentionally returns false for unknown/unhandled tags in the else branch, even though order() returns .eq for matching unknown tags. This semantic difference is by design.

Applied to files:

  • src/env_var.zig
  • src/string/immutable.zig
📚 Learning: 2025-09-02T19:17:26.376Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 0
File: :0-0
Timestamp: 2025-09-02T19:17:26.376Z
Learning: In Bun's Zig codebase, when handling error unions where the same cleanup operation (like `rawFree`) needs to be performed regardless of success or failure, prefer using boolean folding with `else |err| switch (err)` over duplicating the cleanup call in multiple switch branches. This approach avoids code duplication while maintaining compile-time error checking.

Applied to files:

  • src/env_var.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to **/*.zig : Use consistent parameter name `globalObject` instead of `ctx` in Zig constructor and method implementations

Applied to files:

  • src/env_var.zig
  • src/css/css_parser.zig
📚 Learning: 2025-09-06T03:37:41.154Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 22229
File: src/bundler/LinkerGraph.zig:0-0
Timestamp: 2025-09-06T03:37:41.154Z
Learning: In Bun's codebase, when checking import record source indices in src/bundler/LinkerGraph.zig, prefer using `if (import_index >= self.import_records.len)` bounds checking over `isValid()` checks, as the bounds check is more robust and `isValid()` is a strict subset of this condition.

Applied to files:

  • src/env_var.zig
  • src/string/immutable.zig
📚 Learning: 2025-10-24T10:43:09.398Z
Learnt from: fmguerreiro
Repo: oven-sh/bun PR: 23774
File: src/install/PackageManager/updatePackageJSONAndInstall.zig:548-548
Timestamp: 2025-10-24T10:43:09.398Z
Learning: In Bun's Zig codebase, the `as(usize, intCast(...))` cast pattern triggers a Zig compiler bug that causes compilation to hang indefinitely when used in complex control flow contexts (loops + short-circuit operators + optional unwrapping). Avoid this pattern and use simpler alternatives like just `intCast(...)` if type casting is necessary.

Applied to files:

  • src/env_var.zig
  • src/css/css_parser.zig
  • src/string/immutable.zig
📚 Learning: 2025-11-12T04:11:52.293Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 24622
File: src/deps/uws/us_socket_t.zig:112-113
Timestamp: 2025-11-12T04:11:52.293Z
Learning: In Bun's Zig codebase, when passing u32 values to C FFI functions that expect c_uint parameters, no explicit intCast is needed because c_uint is equivalent to u32 on Bun's target platforms and Zig allows implicit coercion between equivalent types. This pattern is used consistently throughout src/deps/uws/us_socket_t.zig in functions like setTimeout, setLongTimeout, and setKeepalive.

Applied to files:

  • src/bun.js/api/bun/socket/SocketAddress.zig
📚 Learning: 2025-10-18T01:49:31.037Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23755
File: src/bun.js/api/bun/socket/SocketConfig.bindv2.ts:58-58
Timestamp: 2025-10-18T01:49:31.037Z
Learning: In Bun's bindgenv2 TypeScript bindings (e.g., src/bun.js/api/bun/socket/SocketConfig.bindv2.ts), the pattern `b.String.loose.nullable.loose` is intentional and not a duplicate. The first `.loose` applies to the String type (loose string conversion), while the second `.loose` applies to the nullable (loose nullable, treating all falsy values as null rather than just null/undefined).

Applied to files:

  • src/bun.js/api/bun/socket/SocketAddress.zig
📚 Learning: 2025-11-24T18:36:59.706Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:59.706Z
Learning: Applies to src/bun.js/bindings/v8/test/v8/v8.test.ts : Add corresponding test cases to test/v8/v8.test.ts using checkSameOutput() function to compare Node.js and Bun output

Applied to files:

  • src/bun.js/api/bun/socket/SocketAddress.zig
📚 Learning: 2025-09-02T18:25:27.976Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 22227
File: src/allocators/allocation_scope.zig:284-314
Timestamp: 2025-09-02T18:25:27.976Z
Learning: In bun's custom Zig implementation, the `#` prefix for private fields is valid syntax and should not be flagged as invalid. The syntax `#fieldname` creates private fields that cannot be accessed from outside the defining struct, and usage like `self.#fieldname` is correct within the same struct. This applies to fields like `#parent`, `#state`, `#allocator`, `#trace`, etc. throughout the codebase.

Applied to files:

  • src/css/css_parser.zig
📚 Learning: 2025-09-04T02:04:43.094Z
Learnt from: Jarred-Sumner
Repo: oven-sh/bun PR: 22278
File: src/ast/E.zig:980-1003
Timestamp: 2025-09-04T02:04:43.094Z
Learning: In Bun's Zig codebase, `as(i32, u8_or_u16_value)` is sufficient for casting u8/u16 to i32 in comparison operations. `intCast` is not required in this context, and the current casting approach compiles successfully.

Applied to files:

  • src/css/css_parser.zig
  • src/string/immutable.zig
📚 Learning: 2025-09-02T17:09:17.391Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 22227
File: src/allocators.zig:778-782
Timestamp: 2025-09-02T17:09:17.391Z
Learning: In Zig's bun codebase, the `isDefault` function in `src/allocators.zig` only needs to compare `allocator.vtable == c_allocator.vtable` rather than also checking the `ptr` field, because: (1) the codebase never creates multiple allocators that use `c_allocator.vtable` but have different `ptr`s, and (2) the default allocator vtable ignores the `ptr` field anyway, so any allocators sharing the same vtable would function identically.

Applied to files:

  • src/string/immutable.zig
📚 Learning: 2025-11-24T18:37:44.864Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/AGENTS.md:0-0
Timestamp: 2025-11-24T18:37:44.864Z
Learning: Applies to src/**/*.py : Use snake_case for variable and function names in Python

Applied to files:

  • src/string/immutable.zig
🔇 Additional comments (10)
src/env_var.zig (1)

294-296: LGTM! Clean unification refactor.

The replacement of std.ascii.eqlIgnoreCase with bun.strings.eqlCaseInsensitiveASCII is a clean refactor that unifies the codebase's case-insensitive ASCII comparison logic. The semantic equivalence maintains correct boolean environment variable parsing behavior for falsy values.

src/bun.js/api/bun/socket/SocketAddress.zig (1)

512-516: New eqlCaseInsensitiveASCII checks are correct and bounds-safe

The switch to bun.strings.eqlCaseInsensitiveASCII(slice[0..4], "ipv4"/"ipv6") looks good: the prior fam_str.length() != 4 guard guarantees slice[0..4] is in-bounds, and behavior stays restricted to ASCII case-insensitive "ipv4"/"ipv6" for 8‑bit strings with unchanged error handling for everything else.

src/http.zig (3)

589-592: Connection header comparison correctly migrated to unified helper

connection_value is compared against the full "close" token, and the loop already works with the exact header slice. Delegating to bun.strings.eqlCaseInsensitiveASCII (which in turn enforces equal length) preserves the old semantics while centralizing the case-insensitive logic.


611-615: Upgrade header h2/h2c checks remain length-safe and semantically equivalent

The new checks against "h2"/"h2c" using bun.strings.eqlCaseInsensitiveASCII still require an exact token match and keep the previous behavior of only marking upgrade_state as pending when the Upgrade value is something else.


2359-2421: Origin equality for redirects now uses unified ASCII-insensitive comparator

Normalizing with strings.withoutTrailingSlash(...) on both sides and then calling strings.eqlCaseInsensitiveASCII keeps the original “same-origin ignoring case and trailing slash” intent, while routing all such checks through the single helper. This looks correct for all three redirect URL shapes (absolute with scheme, protocol-relative, relative).

src/string/immutable.zig (4)

53-62: containsCaseInsensitiveASCII safely reuses eqlCaseInsensitiveASCII

The while (start + str.len <= self.len) guard ensures the slice passed to eqlCaseInsensitiveASCII is always str.len long, so the helper’s implicit length check is satisfied and semantics match the previous per-byte loop.


745-747: startsWithCaseInsensitiveAscii correctly delegates to unified comparator

The prefix length check plus self[0..prefix.len] means eqlCaseInsensitiveASCII is always called on equal-length slices, giving the expected ASCII case-insensitive “starts with” behavior without any extra flags.


971-977: New eqlCaseInsensitiveASCII wrapper cleanly centralizes ASCII ignore-case

Exposing pub inline fn eqlCaseInsensitiveASCII(a, b) over std.ascii.eqlIgnoreCase provides a single, well-named entry point for ASCII case-insensitive equality and replaces the previous flag-based variants without changing length-check semantics.


979-992: eqlCaseInsensitiveT’s u8 fast path now shares the same semantics as eqlCaseInsensitiveASCII

Adding if (comptime T == u8) return eqlCaseInsensitiveASCII(a, b); routes all byte-slice comparisons through the unified helper, avoiding duplicated logic while keeping the existing length and ASCII-only assumptions intact for non‑u8 types. Based on learnings, not suggesting any style-only refactors here.

src/css/css_parser.zig (1)

873-880: Case-insensitive ASCII equality unification looks correct across parsing sites

All the swapped comparisons to bun.strings.eqlCaseInsensitiveASCII (enum_property_util, DefineEnumProperty, expectIdentMatching / expectFunctionMatching, URL helpers, StyleSheetParser.next charset handling, and nth.parse_n / parse_n_dash_digits) preserve the original intent: strict ASCII case-insensitive full-identifier matches where the spec requires it. No prefix-vs-equality regressions or length mismatches are introduced, and the nth helpers still implement the correct An+B forms.

Based on learnings, this focuses purely on correctness rather than style; please just confirm CI covers the touched nth/URL/at-rule paths.

Also applies to: 895-907, 4190-4201, 4216-4227, 4254-4281, 4283-4313, 4618-4674, 4710-4723, 6847-6858


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/css/values/length.zig (1)

446-452: Bug: tryOp and tryOpTo ignore other and call this.toPx() twice

Both tryOp and tryOpTo compute b from this.toPx() instead of other.toPx(), so mixed-unit operations fallback paths never actually see the right-hand operand.

Consider fixing as:

-        const a = this.toPx();
-        const b = this.toPx();
+        const a = this.toPx();
+        const b = other.toPx();

and similarly in tryOpTo:

-        const a = this.toPx();
-        const b = this.toPx();
+        const a = this.toPx();
+        const b = other.toPx();

so the second operand is correctly incorporated in the px-based operations.

Also applies to: 472-476

src/css/values/angle.zig (1)

261-283: Bug in Angle.opTo: other_tag uses this.* instead of other.*

Angle.opTo currently does:

const self_tag: u8 = @intFromEnum(this.*);
const other_tag: u8 = @intFromEnum(this.*); // uses this.* twice
...
const switch_val: u8 = self_tag | other_tag;

This means switch_val is always derived solely from this’s tag. For mixed-unit inputs (e.g. .deg vs .rad), the function will incorrectly enter one of the “same-unit” arms (DEG | DEG, etc.) instead of falling back to the else case that converts both sides to degrees, and will read the wrong union field from other.

Fixing other_tag to use other.* restores the intended behavior:

-        const self_tag: u8 = @intFromEnum(this.*);
-        const other_tag: u8 = @intFromEnum(this.*);
+        const self_tag: u8 = @intFromEnum(this.*);
+        const other_tag: u8 = @intFromEnum(other.*);
...
-        const switch_val: u8 = self_tag | other_tag;
+        const switch_val: u8 = self_tag | other_tag;

(Only the other_tag assignment needs to change; the rest of the logic then correctly routes mixed units to the generic else branch.)

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6745bda and 006261237a4550324b39562bfa39dae5e7ed507e.

📒 Files selected for processing (48)
  • src/bun.js/api/crypto/EVP.zig (1 hunks)
  • src/bun.js/node/path.zig (1 hunks)
  • src/bun.js/uuid.zig (1 hunks)
  • src/bun.zig (4 hunks)
  • src/cli/create_command.zig (1 hunks)
  • src/cli/pack_command.zig (1 hunks)
  • src/cli/publish_command.zig (1 hunks)
  • src/css/css_parser.zig (11 hunks)
  • src/css/media_query.zig (2 hunks)
  • src/css/properties/animation.zig (2 hunks)
  • src/css/properties/background.zig (2 hunks)
  • src/css/properties/css_modules.zig (1 hunks)
  • src/css/properties/custom.zig (4 hunks)
  • src/css/properties/font.zig (1 hunks)
  • src/css/properties/generate_properties.ts (2 hunks)
  • src/css/properties/grid.zig (2 hunks)
  • src/css/properties/transform.zig (10 hunks)
  • src/css/rules/container.zig (1 hunks)
  • src/css/rules/font_face.zig (2 hunks)
  • src/css/rules/font_palette_values.zig (2 hunks)
  • src/css/rules/keyframes.zig (2 hunks)
  • src/css/rules/property.zig (1 hunks)
  • src/css/rules/supports.zig (2 hunks)
  • src/css/selectors/parser.zig (9 hunks)
  • src/css/targets.zig (1 hunks)
  • src/css/values/angle.zig (2 hunks)
  • src/css/values/color.zig (3 hunks)
  • src/css/values/easing.zig (2 hunks)
  • src/css/values/gradient.zig (3 hunks)
  • src/css/values/ident.zig (1 hunks)
  • src/css/values/image.zig (1 hunks)
  • src/css/values/length.zig (2 hunks)
  • src/css/values/resolution.zig (2 hunks)
  • src/css/values/syntax.zig (1 hunks)
  • src/css/values/time.zig (2 hunks)
  • src/deps/picohttp.zig (3 hunks)
  • src/http.zig (3 hunks)
  • src/http/Headers.zig (2 hunks)
  • src/http/websocket_client/WebSocketUpgradeClient.zig (6 hunks)
  • src/install/repository.zig (4 hunks)
  • src/options.zig (1 hunks)
  • src/output.zig (1 hunks)
  • src/resolver/resolve_path.zig (4 hunks)
  • src/sql/postgres/DataCell.zig (3 hunks)
  • src/string.zig (2 hunks)
  • src/string/immutable.zig (3 hunks)
  • src/url.zig (3 hunks)
  • src/which.zig (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
src/**/*.{cpp,zig}

📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)

src/**/*.{cpp,zig}: Use bun bd or bun run build:debug to build debug versions for C++ and Zig source files; creates debug build at ./build/debug/bun-debug
Run tests using bun bd test <test-file> with the debug build; never use bun test directly as it will not include your changes
Execute files using bun bd <file> <...args>; never use bun <file> directly as it will not include your changes
Enable debug logs for specific scopes using BUN_DEBUG_$(SCOPE)=1 environment variable
Code generation happens automatically as part of the build process; no manual code generation commands are required

Files:

  • src/which.zig
  • src/css/rules/container.zig
  • src/css/rules/font_palette_values.zig
  • src/css/values/image.zig
  • src/css/values/time.zig
  • src/output.zig
  • src/css/values/length.zig
  • src/css/properties/css_modules.zig
  • src/resolver/resolve_path.zig
  • src/http/Headers.zig
  • src/url.zig
  • src/css/properties/transform.zig
  • src/css/media_query.zig
  • src/css/properties/grid.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/css/values/syntax.zig
  • src/css/properties/custom.zig
  • src/css/values/angle.zig
  • src/css/values/easing.zig
  • src/cli/pack_command.zig
  • src/bun.js/uuid.zig
  • src/string.zig
  • src/http.zig
  • src/css/values/ident.zig
  • src/bun.js/node/path.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/properties/font.zig
  • src/css/rules/supports.zig
  • src/css/targets.zig
  • src/cli/publish_command.zig
  • src/bun.zig
  • src/install/repository.zig
  • src/css/rules/keyframes.zig
  • src/sql/postgres/DataCell.zig
  • src/css/rules/property.zig
  • src/css/css_parser.zig
  • src/options.zig
  • src/css/values/color.zig
  • src/css/values/resolution.zig
  • src/css/properties/background.zig
  • src/css/rules/font_face.zig
  • src/cli/create_command.zig
  • src/css/values/gradient.zig
  • src/css/selectors/parser.zig
  • src/deps/picohttp.zig
  • src/css/properties/animation.zig
  • src/string/immutable.zig
src/**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)

Use bun.Output.scoped(.${SCOPE}, .hidden) for creating debug logs in Zig code

Implement core functionality in Zig, typically in its own directory in src/

src/**/*.zig: Zig source code should be organized in src/*.zig for core runtime, JavaScript bindings, and package manager
In Zig code, be careful with allocators and use defer for cleanup to manage memory properly
Use BUN_DEBUG_QUIET_LOGS=1 to disable debug logging, or BUN_DEBUG_<scopeName>=1 to enable specific Output.scoped calls in debug builds
Run bun run zig:check-all to compile the Zig code on all platforms when making platform-specific changes

src/**/*.zig: Private fields in Zig are fully supported using the # prefix: struct { #foo: u32 };
Use decl literals in Zig for declaration initialization: const decl: Decl = .{ .binding = 0, .value = 0 };
Prefer @import at the bottom of the file (auto formatter will move them automatically)

Files:

  • src/which.zig
  • src/css/rules/container.zig
  • src/css/rules/font_palette_values.zig
  • src/css/values/image.zig
  • src/css/values/time.zig
  • src/output.zig
  • src/css/values/length.zig
  • src/css/properties/css_modules.zig
  • src/resolver/resolve_path.zig
  • src/http/Headers.zig
  • src/url.zig
  • src/css/properties/transform.zig
  • src/css/media_query.zig
  • src/css/properties/grid.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/css/values/syntax.zig
  • src/css/properties/custom.zig
  • src/css/values/angle.zig
  • src/css/values/easing.zig
  • src/cli/pack_command.zig
  • src/bun.js/uuid.zig
  • src/string.zig
  • src/http.zig
  • src/css/values/ident.zig
  • src/bun.js/node/path.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/properties/font.zig
  • src/css/rules/supports.zig
  • src/css/targets.zig
  • src/cli/publish_command.zig
  • src/bun.zig
  • src/install/repository.zig
  • src/css/rules/keyframes.zig
  • src/sql/postgres/DataCell.zig
  • src/css/rules/property.zig
  • src/css/css_parser.zig
  • src/options.zig
  • src/css/values/color.zig
  • src/css/values/resolution.zig
  • src/css/properties/background.zig
  • src/css/rules/font_face.zig
  • src/cli/create_command.zig
  • src/css/values/gradient.zig
  • src/css/selectors/parser.zig
  • src/deps/picohttp.zig
  • src/css/properties/animation.zig
  • src/string/immutable.zig
**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/zig-javascriptcore-classes.mdc)

**/*.zig: Expose generated bindings in Zig structs using pub const js = JSC.Codegen.JS<ClassName> with trait conversion methods: toJS, fromJS, and fromJSDirect
Use consistent parameter name globalObject instead of ctx in Zig constructor and method implementations
Use bun.JSError!JSValue return type for Zig methods and constructors to enable proper error handling and exception propagation
Implement resource cleanup using deinit() method that releases resources, followed by finalize() called by the GC that invokes deinit() and frees the pointer
Use JSC.markBinding(@src()) in finalize methods for debugging purposes before calling deinit()
For methods returning cached properties in Zig, declare external C++ functions using extern fn and callconv(JSC.conv) calling convention
Implement getter functions with naming pattern get<PropertyName> in Zig that accept this and globalObject parameters and return JSC.JSValue
Access JavaScript CallFrame arguments using callFrame.argument(i), check argument count with callFrame.argumentCount(), and get this with callFrame.thisValue()
For reference-counted objects, use .deref() in finalize instead of destroy() to release references to other JS objects

Files:

  • src/which.zig
  • src/css/rules/container.zig
  • src/css/rules/font_palette_values.zig
  • src/css/values/image.zig
  • src/css/values/time.zig
  • src/output.zig
  • src/css/values/length.zig
  • src/css/properties/css_modules.zig
  • src/resolver/resolve_path.zig
  • src/http/Headers.zig
  • src/url.zig
  • src/css/properties/transform.zig
  • src/css/media_query.zig
  • src/css/properties/grid.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/css/values/syntax.zig
  • src/css/properties/custom.zig
  • src/css/values/angle.zig
  • src/css/values/easing.zig
  • src/cli/pack_command.zig
  • src/bun.js/uuid.zig
  • src/string.zig
  • src/http.zig
  • src/css/values/ident.zig
  • src/bun.js/node/path.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/properties/font.zig
  • src/css/rules/supports.zig
  • src/css/targets.zig
  • src/cli/publish_command.zig
  • src/bun.zig
  • src/install/repository.zig
  • src/css/rules/keyframes.zig
  • src/sql/postgres/DataCell.zig
  • src/css/rules/property.zig
  • src/css/css_parser.zig
  • src/options.zig
  • src/css/values/color.zig
  • src/css/values/resolution.zig
  • src/css/properties/background.zig
  • src/css/rules/font_face.zig
  • src/cli/create_command.zig
  • src/css/values/gradient.zig
  • src/css/selectors/parser.zig
  • src/deps/picohttp.zig
  • src/css/properties/animation.zig
  • src/string/immutable.zig
src/**/*.{ts,zig,cpp}

📄 CodeRabbit inference engine (CLAUDE.md)

Always use absolute paths in file operations

Files:

  • src/which.zig
  • src/css/rules/container.zig
  • src/css/rules/font_palette_values.zig
  • src/css/values/image.zig
  • src/css/values/time.zig
  • src/output.zig
  • src/css/values/length.zig
  • src/css/properties/css_modules.zig
  • src/resolver/resolve_path.zig
  • src/http/Headers.zig
  • src/url.zig
  • src/css/properties/transform.zig
  • src/css/media_query.zig
  • src/css/properties/grid.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/css/values/syntax.zig
  • src/css/properties/custom.zig
  • src/css/values/angle.zig
  • src/css/values/easing.zig
  • src/cli/pack_command.zig
  • src/bun.js/uuid.zig
  • src/string.zig
  • src/http.zig
  • src/css/values/ident.zig
  • src/bun.js/node/path.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/properties/font.zig
  • src/css/rules/supports.zig
  • src/css/targets.zig
  • src/cli/publish_command.zig
  • src/css/properties/generate_properties.ts
  • src/bun.zig
  • src/install/repository.zig
  • src/css/rules/keyframes.zig
  • src/sql/postgres/DataCell.zig
  • src/css/rules/property.zig
  • src/css/css_parser.zig
  • src/options.zig
  • src/css/values/color.zig
  • src/css/values/resolution.zig
  • src/css/properties/background.zig
  • src/css/rules/font_face.zig
  • src/cli/create_command.zig
  • src/css/values/gradient.zig
  • src/css/selectors/parser.zig
  • src/deps/picohttp.zig
  • src/css/properties/animation.zig
  • src/string/immutable.zig
src/**/*.{ts,zig}

📄 CodeRabbit inference engine (CLAUDE.md)

Avoid shell commands in code - don't use find or grep; use Bun's Glob and built-in tools instead

Files:

  • src/which.zig
  • src/css/rules/container.zig
  • src/css/rules/font_palette_values.zig
  • src/css/values/image.zig
  • src/css/values/time.zig
  • src/output.zig
  • src/css/values/length.zig
  • src/css/properties/css_modules.zig
  • src/resolver/resolve_path.zig
  • src/http/Headers.zig
  • src/url.zig
  • src/css/properties/transform.zig
  • src/css/media_query.zig
  • src/css/properties/grid.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/css/values/syntax.zig
  • src/css/properties/custom.zig
  • src/css/values/angle.zig
  • src/css/values/easing.zig
  • src/cli/pack_command.zig
  • src/bun.js/uuid.zig
  • src/string.zig
  • src/http.zig
  • src/css/values/ident.zig
  • src/bun.js/node/path.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/properties/font.zig
  • src/css/rules/supports.zig
  • src/css/targets.zig
  • src/cli/publish_command.zig
  • src/css/properties/generate_properties.ts
  • src/bun.zig
  • src/install/repository.zig
  • src/css/rules/keyframes.zig
  • src/sql/postgres/DataCell.zig
  • src/css/rules/property.zig
  • src/css/css_parser.zig
  • src/options.zig
  • src/css/values/color.zig
  • src/css/values/resolution.zig
  • src/css/properties/background.zig
  • src/css/rules/font_face.zig
  • src/cli/create_command.zig
  • src/css/values/gradient.zig
  • src/css/selectors/parser.zig
  • src/deps/picohttp.zig
  • src/css/properties/animation.zig
  • src/string/immutable.zig
🧠 Learnings (55)
📓 Common learnings
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 24423
File: test/js/node/path/browserify.test.js:472-475
Timestamp: 2025-11-07T17:28:58.045Z
Learning: markovejnovic prefers functional programming patterns (e.g., using reduce) over imperative loops and does not want style-based readability suggestions unless there's a concrete technical reason beyond personal preference.
<!--
📚 Learning: 2025-09-12T18:16:50.754Z
Learnt from: RiskyMH
Repo: oven-sh/bun PR: 22606
File: src/glob/GlobWalker.zig:449-452
Timestamp: 2025-09-12T18:16:50.754Z
Learning: For Bun codebase: prefer using `std.fs.path.sep` over manual platform separator detection, and use `bun.strings.lastIndexOfChar` instead of `std.mem.lastIndexOfScalar` for string operations.

Applied to files:

  • src/which.zig
  • src/resolver/resolve_path.zig
  • src/bun.js/uuid.zig
  • src/bun.js/node/path.zig
  • src/bun.zig
  • src/css/values/resolution.zig
  • src/css/rules/font_face.zig
  • src/css/selectors/parser.zig
📚 Learning: 2025-10-13T06:54:58.043Z
Learnt from: robobun
Repo: oven-sh/bun PR: 0
File: :0-0
Timestamp: 2025-10-13T06:54:58.043Z
Learning: File extensions in Bun's module resolution are case-sensitive by design, and there are no existing precedents in the codebase for case-insensitive HTML file detection.

Applied to files:

  • src/which.zig
📚 Learning: 2025-11-24T18:36:33.069Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Applies to src/**/*.zig : Run `bun run zig:check-all` to compile the Zig code on all platforms when making platform-specific changes

Applied to files:

  • src/which.zig
  • src/bun.zig
📚 Learning: 2025-09-06T03:37:41.154Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 22229
File: src/bundler/LinkerGraph.zig:0-0
Timestamp: 2025-09-06T03:37:41.154Z
Learning: In Bun's codebase, when checking import record source indices in src/bundler/LinkerGraph.zig, prefer using `if (import_index >= self.import_records.len)` bounds checking over `isValid()` checks, as the bounds check is more robust and `isValid()` is a strict subset of this condition.

Applied to files:

  • src/which.zig
  • src/css/values/length.zig
  • src/css/properties/css_modules.zig
  • src/css/properties/grid.zig
  • src/css/properties/custom.zig
  • src/css/values/ident.zig
  • src/bun.js/node/path.zig
  • src/css/targets.zig
  • src/bun.zig
  • src/css/css_parser.zig
  • src/css/values/resolution.zig
📚 Learning: 2025-11-12T07:15:00.763Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 24631
File: src/install/resolution.zig:375-376
Timestamp: 2025-11-12T07:15:00.763Z
Learning: In src/install/resolution.zig, the eql() function intentionally returns false for unknown/unhandled tags in the else branch, even though order() returns .eq for matching unknown tags. This semantic difference is by design.

Applied to files:

  • src/css/rules/container.zig
  • src/css/values/image.zig
  • src/output.zig
  • src/css/values/length.zig
  • src/url.zig
  • src/css/properties/transform.zig
  • src/css/media_query.zig
  • src/css/values/angle.zig
  • src/css/values/easing.zig
  • src/cli/pack_command.zig
  • src/string.zig
  • src/css/values/ident.zig
  • src/bun.js/node/path.zig
  • src/css/rules/supports.zig
  • src/css/values/resolution.zig
  • src/css/values/gradient.zig
  • src/string/immutable.zig
📚 Learning: 2025-11-24T18:34:55.173Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/building-bun.mdc:0-0
Timestamp: 2025-11-24T18:34:55.173Z
Learning: Applies to src/**/*.zig : Use `bun.Output.scoped(.${SCOPE}, .hidden)` for creating debug logs in Zig code

Applied to files:

  • src/output.zig
📚 Learning: 2025-11-24T18:36:33.069Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Applies to src/**/*.zig : Use `BUN_DEBUG_QUIET_LOGS=1` to disable debug logging, or `BUN_DEBUG_<scopeName>=1` to enable specific Output.scoped calls in debug builds

Applied to files:

  • src/output.zig
📚 Learning: 2025-10-16T02:17:35.237Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/analytics.zig:15-21
Timestamp: 2025-10-16T02:17:35.237Z
Learning: In src/analytics.zig and similar files using bun.EnvVar boolean environment variables: the new EnvVar API for boolean flags (e.g., bun.EnvVar.do_not_track.get(), bun.EnvVar.ci.get()) is designed to parse and return boolean values from environment variables, not just check for their presence. This is an intentional design change from the previous presence-based checks using bun.getenvZ().

Applied to files:

  • src/output.zig
  • src/http/Headers.zig
  • src/url.zig
  • src/css/media_query.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/css/values/syntax.zig
  • src/css/properties/custom.zig
  • src/bun.js/uuid.zig
  • src/css/values/ident.zig
  • src/css/targets.zig
  • src/cli/publish_command.zig
  • src/bun.zig
  • src/css/css_parser.zig
  • src/css/values/color.zig
  • src/css/values/resolution.zig
  • src/css/rules/font_face.zig
  • src/deps/picohttp.zig
📚 Learning: 2025-10-18T02:06:31.606Z
Learnt from: pfgithub
Repo: oven-sh/bun PR: 23796
File: src/bun.js/test/Execution.zig:624-625
Timestamp: 2025-10-18T02:06:31.606Z
Learning: In Zig files using bun.Output.scoped(), the visibility level `.visible` means logs are enabled by default in debug builds unless `BUN_DEBUG_QUIET_LOGS=1` is set; if that environment variable is set, the logs can be re-enabled with `BUN_DEBUG_<scope>=1`. Use `.visible` for logs that should appear by default in debug builds, and `.hidden` for logs that require explicit opt-in via `BUN_DEBUG_<scope>=1`.

Applied to files:

  • src/output.zig
📚 Learning: 2025-11-24T18:37:11.466Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/js/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:37:11.466Z
Learning: Applies to src/js/{builtins,node,bun,thirdparty,internal}/**/*.{ts,js} : Use `$debug()` for debug logging and `$assert()` for assertions; both are stripped in release builds

Applied to files:

  • src/output.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to **/*.zig : Use consistent parameter name `globalObject` instead of `ctx` in Zig constructor and method implementations

Applied to files:

  • src/output.zig
  • src/url.zig
  • src/css/properties/transform.zig
  • src/css/values/syntax.zig
  • src/css/values/angle.zig
  • src/bun.zig
  • src/css/rules/keyframes.zig
  • src/css/css_parser.zig
  • src/css/values/color.zig
  • src/deps/picohttp.zig
📚 Learning: 2025-10-16T21:24:52.779Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/crash_handler.zig:1415-1423
Timestamp: 2025-10-16T21:24:52.779Z
Learning: When a boolean EnvVar in src/envvars.zig is defined with a default value (e.g., `.default = false`), the `get()` method returns `bool` instead of `?bool`. This means you cannot distinguish between "environment variable not set" and "environment variable explicitly set to the default value". For opt-out scenarios where detection of explicit setting is needed (like `BUN_ENABLE_CRASH_REPORTING` on platforms where crash reporting defaults to enabled), either: (1) don't provide a default value so `get()` returns `?bool`, or (2) use the returned boolean directly instead of only checking if it's true.

Applied to files:

  • src/output.zig
📚 Learning: 2025-11-24T18:34:55.173Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/building-bun.mdc:0-0
Timestamp: 2025-11-24T18:34:55.173Z
Learning: Applies to src/**/*.{cpp,zig} : Enable debug logs for specific scopes using `BUN_DEBUG_$(SCOPE)=1` environment variable

Applied to files:

  • src/output.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to **/*.zig : Use `JSC.markBinding(src())` in finalize methods for debugging purposes before calling `deinit()`

Applied to files:

  • src/output.zig
📚 Learning: 2025-10-18T20:50:47.750Z
Learnt from: theshadow27
Repo: oven-sh/bun PR: 23798
File: src/bun.js/telemetry.zig:366-373
Timestamp: 2025-10-18T20:50:47.750Z
Learning: In Bun's Zig codebase (src/bun.js/bindings/JSValue.zig), the JSValue enum uses `.null` (not `.js_null`) for JavaScript's null value. Only `js_undefined` has the `js_` prefix to avoid collision with Zig's built-in `undefined` keyword. The correct enum fields are: `js_undefined`, `null`, `true`, `false`, and `zero`.

Applied to files:

  • src/css/values/length.zig
  • src/css/values/syntax.zig
  • src/bun.js/uuid.zig
  • src/css/values/ident.zig
  • src/bun.js/node/path.zig
  • src/css/targets.zig
  • src/css/values/color.zig
📚 Learning: 2025-10-01T21:59:54.571Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23169
File: src/bun.js/bindings/webcore/JSDOMConvertEnumeration.h:47-74
Timestamp: 2025-10-01T21:59:54.571Z
Learning: In the new bindings generator (bindgenv2) for `src/bun.js/bindings/webcore/JSDOMConvertEnumeration.h`, the context-aware enumeration conversion overloads intentionally use stricter validation (requiring `value.isString()` without ToString coercion), diverging from Web IDL semantics. This is a design decision documented in comments.

Applied to files:

  • src/css/values/length.zig
  • src/css/values/syntax.zig
  • src/css/properties/custom.zig
  • src/bun.js/uuid.zig
  • src/css/values/ident.zig
  • src/css/values/color.zig
📚 Learning: 2025-09-04T02:04:43.094Z
Learnt from: Jarred-Sumner
Repo: oven-sh/bun PR: 22278
File: src/ast/E.zig:980-1003
Timestamp: 2025-09-04T02:04:43.094Z
Learning: In Bun's Zig codebase, `as(i32, u8_or_u16_value)` is sufficient for casting u8/u16 to i32 in comparison operations. `intCast` is not required in this context, and the current casting approach compiles successfully.

Applied to files:

  • src/css/values/length.zig
  • src/css/values/angle.zig
  • src/string.zig
  • src/bun.js/node/path.zig
  • src/bun.zig
  • src/css/css_parser.zig
  • src/css/values/resolution.zig
📚 Learning: 2025-11-24T18:36:38.104Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:38.104Z
Learning: Applies to src/**/*.zig : Prefer `import` at the bottom of the file (auto formatter will move them automatically)

Applied to files:

  • src/css/properties/css_modules.zig
📚 Learning: 2025-09-02T18:25:27.976Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 22227
File: src/allocators/allocation_scope.zig:284-314
Timestamp: 2025-09-02T18:25:27.976Z
Learning: In bun's custom Zig implementation, the `#` prefix for private fields is valid syntax and should not be flagged as invalid. The syntax `#fieldname` creates private fields that cannot be accessed from outside the defining struct, and usage like `self.#fieldname` is correct within the same struct. This applies to fields like `#parent`, `#state`, `#allocator`, `#trace`, etc. throughout the codebase.

Applied to files:

  • src/css/properties/css_modules.zig
  • src/css/values/syntax.zig
  • src/css/properties/custom.zig
  • src/css/values/ident.zig
  • src/css/rules/keyframes.zig
  • src/css/rules/property.zig
  • src/css/css_parser.zig
  • src/css/values/color.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to **/*.zig : Expose generated bindings in Zig structs using `pub const js = JSC.Codegen.JS<ClassName>` with trait conversion methods: `toJS`, `fromJS`, and `fromJSDirect`

Applied to files:

  • src/css/properties/css_modules.zig
  • src/css/rules/keyframes.zig
📚 Learning: 2025-11-24T18:36:33.069Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Applies to src/**/*.{ts,zig,cpp} : Always use absolute paths in file operations

Applied to files:

  • src/resolver/resolve_path.zig
📚 Learning: 2025-10-08T13:56:00.875Z
Learnt from: Jarred-Sumner
Repo: oven-sh/bun PR: 23373
File: src/bun.js/api/BunObject.zig:2514-2521
Timestamp: 2025-10-08T13:56:00.875Z
Learning: For Bun codebase: prefer using `bun.path` utilities (e.g., `bun.path.joinAbsStringBuf`, `bun.path.join`) over `std.fs.path` functions for path operations.

Applied to files:

  • src/resolver/resolve_path.zig
  • src/bun.js/node/path.zig
📚 Learning: 2025-10-15T22:03:50.832Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/envvars.zig:135-144
Timestamp: 2025-10-15T22:03:50.832Z
Learning: In src/envvars.zig, the boolean feature flag cache uses a single atomic enum and should remain monotonic. Only the string cache (which uses two atomics: ptr and len) requires acquire/release ordering to prevent torn reads.

Applied to files:

  • src/url.zig
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Applies to src/**/*.zig : Implement core functionality in Zig, typically in its own directory in `src/`

Applied to files:

  • src/url.zig
📚 Learning: 2025-09-02T17:09:17.391Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 22227
File: src/allocators.zig:778-782
Timestamp: 2025-09-02T17:09:17.391Z
Learning: In Zig's bun codebase, the `isDefault` function in `src/allocators.zig` only needs to compare `allocator.vtable == c_allocator.vtable` rather than also checking the `ptr` field, because: (1) the codebase never creates multiple allocators that use `c_allocator.vtable` but have different `ptr`s, and (2) the default allocator vtable ignores the `ptr` field anyway, so any allocators sharing the same vtable would function identically.

Applied to files:

  • src/url.zig
  • src/string.zig
  • src/css/values/ident.zig
  • src/css/targets.zig
  • src/bun.zig
  • src/css/values/resolution.zig
📚 Learning: 2025-10-24T10:43:09.398Z
Learnt from: fmguerreiro
Repo: oven-sh/bun PR: 23774
File: src/install/PackageManager/updatePackageJSONAndInstall.zig:548-548
Timestamp: 2025-10-24T10:43:09.398Z
Learning: In Bun's Zig codebase, the `as(usize, intCast(...))` cast pattern triggers a Zig compiler bug that causes compilation to hang indefinitely when used in complex control flow contexts (loops + short-circuit operators + optional unwrapping). Avoid this pattern and use simpler alternatives like just `intCast(...)` if type casting is necessary.

Applied to files:

  • src/css/media_query.zig
  • src/css/values/angle.zig
  • src/string.zig
  • src/css/values/ident.zig
  • src/bun.zig
  • src/css/css_parser.zig
  • src/css/values/resolution.zig
📚 Learning: 2025-09-25T18:39:03.607Z
Learnt from: nektro
Repo: oven-sh/bun PR: 22958
File: src/bun.js/api/crypto/EVP.zig:24-24
Timestamp: 2025-09-25T18:39:03.607Z
Learning: BoringSSL's translated bindings in src/deps/boringssl.translated.zig only provide EVP_blake2b256() and EVP_blake2b512() extern function declarations. EVP_blake2s256() does not exist in BoringSSL bindings, so blake2s256 algorithm support must rely on the EVP_get_digestbyname() fallback mechanism rather than direct function binding in the Algorithm.md() switch statement.

Applied to files:

  • src/bun.js/api/crypto/EVP.zig
📚 Learning: 2025-09-25T18:39:03.607Z
Learnt from: nektro
Repo: oven-sh/bun PR: 22958
File: src/bun.js/api/crypto/EVP.zig:24-24
Timestamp: 2025-09-25T18:39:03.607Z
Learning: BoringSSL does not provide EVP_blake2s256() function binding in Bun's codebase, unlike EVP_blake2b256() and EVP_blake2b512() which are available. For blake2s256 algorithm support, the correct approach is to rely on the EVP_get_digestbyname() fallback mechanism rather than adding a direct function binding to the Algorithm.md() switch statement.

Applied to files:

  • src/bun.js/api/crypto/EVP.zig
📚 Learning: 2025-10-29T19:05:25.638Z
Learnt from: theshadow27
Repo: oven-sh/bun PR: 24063
File: packages/bun-types/telemetry.d.ts:252-261
Timestamp: 2025-10-29T19:05:25.638Z
Learning: In packages/bun-types/telemetry.d.ts and src/telemetry/telemetry.zig, the naming inconsistency between `kind` (public API) and `type` (internal implementation) is intentional. The public API uses `InstrumentInfo.kind: InstrumentKind` with string values ("http", "fetch", etc.) for developer ergonomics, while the internal implementation uses `InstrumentRecord.type: InstrumentType` with numeric enum (0-6) for O(1) dispatch performance. This dual naming provides both ergonomic strings externally and efficient numeric dispatch internally without compromising either developer experience or runtime performance.

Applied to files:

  • src/css/values/syntax.zig
📚 Learning: 2025-11-24T18:36:59.706Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:59.706Z
Learning: Applies to src/bun.js/bindings/v8/src/napi/napi.zig : For each new V8 C++ method, add both GCC/Clang and MSVC mangled symbol names to the V8API struct in src/napi/napi.zig using extern fn declarations

Applied to files:

  • src/css/values/syntax.zig
📚 Learning: 2025-11-24T18:36:59.706Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:59.706Z
Learning: Applies to src/bun.js/bindings/v8/src/symbols.txt : Add symbol names without leading underscore to src/symbols.txt for each new V8 API method

Applied to files:

  • src/css/values/syntax.zig
📚 Learning: 2025-11-11T22:55:04.070Z
Learnt from: pfgithub
Repo: oven-sh/bun PR: 24571
File: src/css/selectors/parser.zig:908-916
Timestamp: 2025-11-11T22:55:04.070Z
Learning: In oven-sh/bun, CSS serialization uses an arena allocator. In src/css/selectors/parser.zig, functions like PseudoClass.toCss and PseudoElement.toCss intentionally do not call deinit on std.Io.Writer.Allocating, scratch buffers, or css.Printer because dest.allocator is an arena and these temporaries are reclaimed when the CSS pass completes. Only debug-only paths (e.g., DeclarationBlock.DebugFmt in src/css/declaration.zig) may explicitly deinit.

Applied to files:

  • src/css/properties/custom.zig
  • src/css/properties/generate_properties.ts
  • src/css/rules/keyframes.zig
  • src/css/selectors/parser.zig
  • src/css/properties/animation.zig
📚 Learning: 2025-09-02T19:17:26.376Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 0
File: :0-0
Timestamp: 2025-09-02T19:17:26.376Z
Learning: In Bun's Zig codebase, when handling error unions where the same cleanup operation (like `rawFree`) needs to be performed regardless of success or failure, prefer using boolean folding with `else |err| switch (err)` over duplicating the cleanup call in multiple switch branches. This approach avoids code duplication while maintaining compile-time error checking.

Applied to files:

  • src/css/values/angle.zig
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Applies to src/bun.js/api/BunObject.zig : Implement getter functions in `src/bun.js/api/BunObject.zig` that return your feature, and export them in the `exportAll()` function

Applied to files:

  • src/bun.js/uuid.zig
  • src/bun.js/node/path.zig
📚 Learning: 2025-10-01T21:49:27.862Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23169
File: src/bun.js/bindings/BunIDLConvert.h:29-42
Timestamp: 2025-10-01T21:49:27.862Z
Learning: In Bun's IDL bindings (src/bun.js/bindings/BunIDLConvert.h), IDLStrictNull intentionally treats both undefined and null as null (using isUndefinedOrNull()), matching WebKit's IDLNull & IDLNullable behavior. This is the correct implementation and should not be changed to only accept null.

Applied to files:

  • src/bun.js/uuid.zig
  • src/css/targets.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to src/bun.js/bindings/generated_classes_list.zig : Include new class bindings in `src/bun.js/bindings/generated_classes_list.zig` to register them with the code generator

Applied to files:

  • src/bun.js/uuid.zig
  • src/bun.js/node/path.zig
  • src/css/rules/keyframes.zig
📚 Learning: 2025-11-24T18:37:47.899Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/AGENTS.md:0-0
Timestamp: 2025-11-24T18:37:47.899Z
Learning: Applies to src/bun.js/bindings/v8/**/<UNKNOWN> : <UNKNOWN>

Applied to files:

  • src/bun.js/uuid.zig
  • src/css/selectors/parser.zig
📚 Learning: 2025-11-24T18:36:59.706Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:59.706Z
Learning: Applies to src/bun.js/bindings/v8/test/v8/v8.test.ts : Add corresponding test cases to test/v8/v8.test.ts using checkSameOutput() function to compare Node.js and Bun output

Applied to files:

  • src/bun.js/uuid.zig
  • src/bun.js/node/path.zig
📚 Learning: 2025-11-24T18:36:59.706Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:59.706Z
Learning: Applies to src/bun.js/bindings/v8/V8*.h : Add BUN_EXPORT visibility attribute to all public V8 API functions to ensure proper symbol export across platforms

Applied to files:

  • src/bun.js/uuid.zig
📚 Learning: 2025-11-11T22:55:08.547Z
Learnt from: pfgithub
Repo: oven-sh/bun PR: 24571
File: src/css/values/url.zig:97-116
Timestamp: 2025-11-11T22:55:08.547Z
Learning: In Zig 0.15, the standard library module `std.io` was renamed to `std.Io` (with capital I). Code using `std.Io.Writer.Allocating` and similar types is correct for Zig 0.15+.

Applied to files:

  • src/string.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/options.zig
  • src/deps/picohttp.zig
📚 Learning: 2025-10-21T20:57:01.892Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23889
File: src/string.zig:751-752
Timestamp: 2025-10-21T20:57:01.892Z
Learning: In Zig code handling bun.String: calling deref() on an empty bun.String (String.empty or after being set to .empty) is well-defined behavior and safely does nothing (no-op). While such calls may be redundant and could be removed for code clarity, their presence is not a correctness issue.

Applied to files:

  • src/string.zig
  • src/bun.zig
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Applies to **/js_*.zig : Use `bun.JSError!JSValue` for proper error propagation in JavaScript bindings

Applied to files:

  • src/css/values/ident.zig
  • src/css/properties/generate_properties.ts
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to **/*.zig : Use `bun.JSError!JSValue` return type for Zig methods and constructors to enable proper error handling and exception propagation

Applied to files:

  • src/css/values/ident.zig
  • src/css/properties/generate_properties.ts
📚 Learning: 2025-11-12T04:11:52.293Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 24622
File: src/deps/uws/us_socket_t.zig:112-113
Timestamp: 2025-11-12T04:11:52.293Z
Learning: In Bun's Zig codebase, when passing u32 values to C FFI functions that expect c_uint parameters, no explicit intCast is needed because c_uint is equivalent to u32 on Bun's target platforms and Zig allows implicit coercion between equivalent types. This pattern is used consistently throughout src/deps/uws/us_socket_t.zig in functions like setTimeout, setLongTimeout, and setKeepalive.

Applied to files:

  • src/bun.js/node/path.zig
📚 Learning: 2025-09-05T18:45:29.200Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 21728
File: src/valkey/js_valkey.zig:0-0
Timestamp: 2025-09-05T18:45:29.200Z
Learning: In JSValkeyClient.cloneWithoutConnecting() in src/valkey/js_valkey.zig, the address/username/password fields must be repointed to the duplicated connection_strings buffer to avoid use-after-free when the original client is destroyed. The original client properly frees connection_strings in ValkeyClient.deinit().

Applied to files:

  • src/http/websocket_client/WebSocketUpgradeClient.zig
📚 Learning: 2025-10-17T20:50:58.644Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23755
File: src/bun.js/api/bun/socket/Handlers.zig:154-159
Timestamp: 2025-10-17T20:50:58.644Z
Learning: In Bun socket configuration error messages (src/bun.js/api/bun/socket/Handlers.zig), use the user-facing JavaScript names "data" and "drain" instead of internal field names "onData" and "onWritable", as these are the names users see in the API according to SocketConfig.bindv2.ts.

Applied to files:

  • src/http/websocket_client/WebSocketUpgradeClient.zig
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Applies to **/*js_bindings.classes.ts : Add JSDoc comments to JavaScript binding definitions in `.classes.ts` files

Applied to files:

  • src/css/properties/generate_properties.ts
📚 Learning: 2025-10-16T17:32:03.074Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/install/PackageManager/PackageManagerOptions.zig:187-193
Timestamp: 2025-10-16T17:32:03.074Z
Learning: In Bun's codebase (particularly in files like src/install/PackageManager/PackageManagerOptions.zig), mixing bun.EnvVar.*.get() and bun.EnvVar.*.platformGet() for environment variable lookups is intentional and safe. The code is protected by compile-time platform checks (Environment.isWindows, etc.), and compilation will fail if the wrong function is used on the wrong platform. This pattern should not be flagged as a consistency issue.

Applied to files:

  • src/bun.zig
📚 Learning: 2025-11-24T18:35:25.883Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/javascriptcore-class.mdc:0-0
Timestamp: 2025-11-24T18:35:25.883Z
Learning: Applies to *.zig : In Zig, declare external C++ functions and wrap them in public methods using the convention `extern fn Bun__ClassName__toJS(...)` and `pub fn toJS(...)`

Applied to files:

  • src/css/rules/keyframes.zig
📚 Learning: 2025-09-25T22:51:15.539Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 22946
File: src/js/internal/sql/postgres.ts:138-143
Timestamp: 2025-09-25T22:51:15.539Z
Learning: In PostgreSQL array serialization for Bun.SQL, typed arrays (Uint8Array, Int32Array, etc.) should always be treated as arrays and expand their elements, not as binary data. BYTEA binary serialization should only use Buffer objects, maintaining consistency with postgres.js behavior. Typed arrays and Buffer have different semantic purposes.

Applied to files:

  • src/sql/postgres/DataCell.zig
📚 Learning: 2025-09-25T01:02:43.263Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 22946
File: src/js/internal/sql/postgres.ts:188-198
Timestamp: 2025-09-25T01:02:43.263Z
Learning: In the PostgreSQL array implementation for Bun.SQL, when getPostgresArrayType returns null for unknown numeric OIDs, throwing an error is not the desired behavior. The user prefers a different approach for handling unknown array type OIDs.

Applied to files:

  • src/sql/postgres/DataCell.zig
📚 Learning: 2025-09-25T01:04:19.262Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 22946
File: src/js/internal/sql/postgres.ts:1185-1416
Timestamp: 2025-09-25T01:04:19.262Z
Learning: In the PostgreSQL array implementation for Bun.SQL, when serializing arrays for JSON/JSONB columns, the user prefers using PostgreSQL array literal format (serializeArray(value, "JSON")) over standard JSON serialization (JSON.stringify(value)). PostgreSQL JSON array handling is different from JavaScript JSON array handling according to the user's requirements.

Applied to files:

  • src/sql/postgres/DataCell.zig
📚 Learning: 2025-10-30T21:52:04.707Z
Learnt from: pfgithub
Repo: oven-sh/bun PR: 24212
File: src/cli/publish_command.zig:782-788
Timestamp: 2025-10-30T21:52:04.707Z
Learning: In the Bun codebase (oven-sh/bun), `enable_ansi_colors` flags are used to gate both ANSI color codes and Unicode box-drawing characters/emoji. This is the established pattern across the codebase.

Applied to files:

  • src/css/values/color.zig
📚 Learning: 2025-11-24T18:36:33.069Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Applies to src/bun.js/bindings/**/*.cpp : When implementing JavaScript classes in C++, define properties using HashTableValue arrays and add iso subspaces for classes with C++ fields, caching structures in ZigGlobalObject

Applied to files:

  • src/css/selectors/parser.zig

@@ -119,7 +119,7 @@ function generatePropertyImpl(property_defs: Record<string, PropertyDef>): strin
// - eql()
// - parse()
// - toCss()
//
//

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Remove unnecessary blank comment line.

The extra blank comment line appears to be unintentional and doesn't improve readability.

-  //
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
//
🤖 Prompt for AI Agents
In src/css/properties/generate_properties.ts around line 122, there is an
unnecessary blank comment line ("//") that should be removed; delete that empty
comment so the file has no stray comment-only line at that position to improve
cleanliness and readability.

@@ -491,7 +491,7 @@ function generatePropertyIdImplFromNameAndPrefix(property_defs: Record<string, P
return Object.entries(property_defs)
.map(([name, meta]) => {
if (name === "unparsed") return "";
return `if (bun.strings.eqlCaseInsensitiveASCIIICheckLength(name1, "${name}")) {
return `if (bun.strings.eqlCaseInsensitiveASCII(name1, "${name}")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Check if generatePropertyIdImplFromNameAndPrefix is called
echo "=== Checking if generatePropertyIdImplFromNameAndPrefix is used ==="
rg -n "generatePropertyIdImplFromNameAndPrefix" --type=ts

# Find the new function in Zig string utilities
echo -e "\n=== Looking for eqlCaseInsensitiveASCII definition ==="
rg -n "fn eqlCaseInsensitiveASCII" --type=zig -A 5

# Check if the old function still exists
echo -e "\n=== Checking if old function eqlCaseInsensitiveASCIIICheckLength still exists ==="
rg -n "eqlCaseInsensitiveASCIIICheckLength" --type=zig

# Check generated file for actual usage
echo -e "\n=== Checking generated Zig file for the function usage ==="
fd "properties_generated.zig" --type f -x cat -n {} \; 2>/dev/null | head -100

# Check the generate_properties.ts file around line 490-500
echo -e "\n=== Content of generate_properties.ts around line 490-500 ==="
sed -n '480,510p' src/css/properties/generate_properties.ts | cat -n

Repository: oven-sh/bun

Length of output: 7970


🏁 Script executed:

#!/bin/bash

# Search for where generatePropertyIdImplFromNameAndPrefix might be called
echo "=== Checking full context of generate_properties.ts file ==="
wc -l src/css/properties/generate_properties.ts

# Get end of file to see if function is exported
echo -e "\n=== Last 50 lines of generate_properties.ts ==="
tail -50 src/css/properties/generate_properties.ts

# Search for imports of this file or function exports
echo -e "\n=== Checking for exports or other function calls in generate_properties.ts ==="
rg -n "export|generatePropertyIdImpl" src/css/properties/generate_properties.ts

# Search for where properties_generated.zig is created
echo -e "\n=== Looking for build/generation scripts ==="
fd -t f "\.ts$" -x rg -l "properties_generated" {}

# Check if there's a run script or main export
echo -e "\n=== Checking if generate_properties.ts has a main export ==="
head -30 src/css/properties/generate_properties.ts

Repository: oven-sh/bun

Length of output: 3221


🏁 Script executed:

#!/bin/bash

# Look at the actual generatePropertyIdImpl function and what it generates
echo "=== Lines 368-420 showing generatePropertyIdImpl and its usage ==="
sed -n '360,425p' src/css/properties/generate_properties.ts | cat -n

Repository: oven-sh/bun

Length of output: 2987


🏁 Script executed:

#!/bin/bash

# Check git history for generatePropertyIdImplFromNameAndPrefix
echo "=== Git log for generatePropertyIdImplFromNameAndPrefix ==="
git log --oneline -p src/css/properties/generate_properties.ts | grep -B5 -A5 "generatePropertyIdImplFromNameAndPrefix" | head -40

# Check when this function was added
echo -e "\n=== Git blame for line 490 ==="
git blame -L 490,495 src/css/properties/generate_properties.ts

# Verify Map.getASCIIICaseInsensitive exists
echo -e "\n=== Looking for getASCIIICaseInsensitive implementation ==="
rg -n "getASCIIICaseInsensitive" --type=ts --type=zig -B 2 -A 5

Repository: oven-sh/bun

Length of output: 22256


Remove unused dead code function generatePropertyIdImplFromNameAndPrefix.

The function generatePropertyIdImplFromNameAndPrefix (lines 490–500) is never called and should be removed. The actual implementation uses Map.getASCIIICaseInsensitive from ComptimeEnumMap instead (line 402), which generates the property matching code correctly. The unused function appears to be leftover from refactoring.

🤖 Prompt for AI Agents
In src/css/properties/generate_properties.ts around lines 490 to 500, remove the
dead/unreferenced function generatePropertyIdImplFromNameAndPrefix which is
never called (leftover from refactor) and ensure there are no remaining
references or exports to it; after deletion, run a quick grep/TS compile to
confirm nothing else depends on that identifier and update any related comments
to reflect that ComptimeEnumMap.Map.getASCIIICaseInsensitive is the active
implementation.

Comment on lines 1215 to 1219
if (bun.strings.startsWithChar(name, '_')) {
this.options.warn(loc.newCustomError(SelectorParseErrorKind{ .unsupported_pseudo_class_or_element = name }));
} else if (this.options.css_modules != null and bun.strings.eqlCaseInsensitiveASCIIICheckLength(name, "local") or bun.strings.eqlCaseInsensitiveASCIIICheckLength(name, "global")) {
} else if (this.options.css_modules != null and bun.strings.eqlCaseInsensitiveASCII(name, "local") or bun.strings.eqlCaseInsensitiveASCII(name, "global")) {
return .{ .err = loc.newCustomError(SelectorParseErrorKind{ .ambiguous_css_module_class = name }) };
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check if the file exists and read the relevant lines
cat -n src/css/selectors/parser.zig | sed -n '1210,1225p'

Repository: oven-sh/bun

Length of output: 958


🏁 Script executed:

# Let's also check more context around this section to understand the logic
cat -n src/css/selectors/parser.zig | sed -n '1200,1280p'

Repository: oven-sh/bun

Length of output: 4629


🏁 Script executed:

# Search for related CSS modules handling to understand intended behavior
rg -A 5 -B 5 "css_modules" src/css/selectors/parser.zig | head -100

Repository: oven-sh/bun

Length of output: 2488


🌐 Web query:

Zig operator precedence and vs or

💡 Result:

In Zig the logical operator and has higher precedence than or, so expressions parse as (a and b) or c (not a and (b or c)). See the Zig operator-precedence table. [1][2]

Example:

  • a and b or c ===> (a and b) or c. [1][2]

Sources:
[1] Zig docs — Precedence (master).
[2] Zig docs — Precedence (0.12.1).


:global pseudo-class incorrectly rejected when CSS modules are disabled due to operator precedence

Line 1217 uses and and or without proper grouping:

} else if (this.options.css_modules != null and bun.strings.eqlCaseInsensitiveASCII(name, "local") or bun.strings.eqlCaseInsensitiveASCII(name, "global")) {

Since and has higher precedence than or in Zig, this evaluates as:

if (((this.options.css_modules != null and eql(name, "local")) or eql(name, "global"))) { ... }

This causes :global to trigger ambiguous_css_module_class even when css_modules is null, which contradicts the correct logic at lines 1256 and 1269 in parseNonTsFunctionalPseudoClass where both conditions explicitly require and this.options.css_modules != null.

Both local and global should only be treated as ambiguous when CSS modules are enabled. Fix by grouping the conditions:

-                } else if (this.options.css_modules != null and bun.strings.eqlCaseInsensitiveASCII(name, "local") or bun.strings.eqlCaseInsensitiveASCII(name, "global")) {
+                } else if (this.options.css_modules != null and (bun.strings.eqlCaseInsensitiveASCII(name, "local") or bun.strings.eqlCaseInsensitiveASCII(name, "global"))) {
🤖 Prompt for AI Agents
In src/css/selectors/parser.zig around lines 1215 to 1219, the conditional mixes
`and` and `or` without grouping so `:global` is treated as ambiguous even when
css_modules is null; change the condition to first check
`this.options.css_modules != null` and then check the name (e.g., `if
(this.options.css_modules != null and (bun.strings.eqlCaseInsensitiveASCII(name,
"local") or bun.strings.eqlCaseInsensitiveASCII(name, "global")))`) so both
`local` and `global` are only considered ambiguous when CSS modules are enabled,
returning the same ambiguous_css_module_class error as intended.

Comment thread src/sql/postgres/DataCell.zig Resolved
@markovejnovic
markovejnovic force-pushed the user/markovejnovic/eqlCaseInsensitiveASCII-unification branch from 0062612 to 1bad8a4 Compare December 1, 2025 22:54
Comment thread src/string/immutable.zig Outdated
pub inline fn eqlCaseInsensitiveASCII(a: string, b: string) bool {
// This is separated into a slow path to reduce code size of the fast path. We're letting LLVM
// decide whether it inlines it or not.
const SlowPathNs = struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be snake_case

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
src/css/values/length.zig (1)

446-452: Bug: tryOp / tryOpTo use this.toPx() for both operands

Both helpers currently compute b from this.toPx() instead of other.toPx(), so mixed-unit ops that fall back to pixels will incorrectly use the left-hand value twice.

Fix by calling other.toPx() for b in both functions:

@@
-        const a = this.toPx();
-        const b = this.toPx();
+        const a = this.toPx();
+        const b = other.toPx();
@@
-        const a = this.toPx();
-        const b = this.toPx();
+        const a = this.toPx();
+        const b = other.toPx();

This will make LengthValue.tryOp / tryOpTo behave correctly when the tags differ but both values are convertible to pixels.

Also applies to: 472-476

src/css/properties/css_modules.zig (1)

64-73: Fix the CI compilation error around the “from” sentinel check

The logic if (bun.strings.eqlCaseInsensitiveASCII(name.v, "from")) return .{ .err = input.newErrorForNextToken() }; is semantically correct for reserving from as a keyword, but CI is currently failing with a Zig compile error reported at this line. Double-check that all references to the old eqlCaseInsensitiveASCII* variants are removed, that bun.strings.eqlCaseInsensitiveASCII is visible with the new two-argument signature on all targets, and re-run bun run zig:check-all to ensure this compiles everywhere before merging.

src/css/properties/animation.zig (1)

172-176: Fix malformed parseString call in fill_mode branch: missing 3 required parameters

In Animation.toCss at line 187-192, the fill_mode branch calls:

css.parse_utility.parseString(dest.allocator).isOk()

This is incomplete. The parseString function signature requires 4 parameters:

  1. allocator: Allocator
  2. comptime T: type
  3. input: []const u8
  4. comptime parse_one: *const fn (*Parser) Result(T)

Your call provides only the allocator. The direction (lines 177-182) and play_state (lines 194-199) branches correctly pass all 4 arguments. Update the fill_mode branch to match:

if (!this.fill_mode.eql(&AnimationFillMode.default()) or
    (!bun.strings.eqlCaseInsensitiveASCII(name_str, "none") and css.parse_utility.parseString(
        dest.allocator,
        AnimationFillMode,
        name_str,
        AnimationFillMode.parse,
    ).isOk()))
{
    try this.fill_mode.toCss(dest);
    try dest.writeChar(' ');
}

This is a compile-time error. Run bun run zig:check-all after fixing to verify compilation across all targets.

src/css/values/color.zig (1)

2876-2914: Fix enum variant typo: @"a99-rgb" should be @"a98-rgb"

At line 2880, the Variants enum defines @"a99-rgb", but the CSS Color Module Level 4 specification defines this color space as a98-rgb. This typo is inconsistent with:

  • Line 2828: the earlier eqlCaseInsensitiveASCII("a98-rgb", colorspace) check
  • Line 3572: the output serialization "a98-rgb"
  • Comments (lines 1478, 1932) and all helper functions that reference a98-rgb

The typo allows the non-standard color(a99-rgb …) syntax to parse while the correct color(a98-rgb …) only works through the manual fallthrough at line 2828. Rename the enum tag to @"a98-rgb" to ensure consistent parsing of both relative and non-relative color() syntax.

♻️ Duplicate comments (4)
src/css/properties/generate_properties.ts (1)

122-122: Remove unnecessary blank comment line.

This extra blank comment line was already flagged in previous reviews and should be removed.

src/sql/postgres/DataCell.zig (1)

585-602: Make NULL check for date/timestamp text strictly case‑sensitive (or drop it)

This branch:

if (bun.strings.eqlCaseInsensitiveASCII(bytes, "NULL")) {
    return SQLDataCell{ .tag = .null, .value = .{ .null = 0 } };
}

treats any case variation of "NULL" (e.g. "null", "Null") as SQL NULL for .date/.timestamp/.timestamptz, even though on the wire NULLs are represented by a -1 length and never as the text "NULL". If bytes are present, they’re actual text data. Elsewhere in this file (array parsing), unquoted NULL is matched case‑sensitively with eqlComptime, and quoted "NULL" is treated as a string.

To keep semantics consistent and avoid silently discarding data that happens to be "null" in user text, this should be case‑sensitive (or removed entirely). For a minimal, consistent fix:

-            } else {
-                if (bun.strings.eqlCaseInsensitiveASCII(bytes, "NULL")) {
-                    return SQLDataCell{ .tag = .null, .value = .{ .null = 0 } };
-                }
+            } else {
+                if (bun.strings.eqlComptime(bytes, "NULL")) {
+                    return SQLDataCell{ .tag = .null, .value = .{ .null = 0 } };
+                }
                 var str = bun.String.init(bytes);

This keeps the unification work but aligns with the array handling and the protocol’s NULL semantics.

src/css/rules/font_face.zig (1)

380-396: Font format and @font-face property name comparisons align with unified helper

  • FontFormat.parse now uses bun.strings.eqlCaseInsensitiveASCII to match "woff", "woff2", "truetype", "opentype", "embedded-opentype", "collection", and "svg". That preserves the intended case-insensitive keyword handling while simplifying the helper.
  • FontFaceDeclarationParser.DeclarationParser.parseValue similarly switches to bun.strings.eqlCaseInsensitiveASCII for "src", "font-family", "font-weight", "font-style", "font-stretch", and "unicode-renage".

These changes are mechanically consistent with the rest of the PR. Note that the "unicode-renage" spelling matches the earlier declaration parser; see the comment in src/css/rules/property.zig about verifying whether this is intended or a typo for "unicode-range".

Also applies to: 671-705

src/css/selectors/parser.zig (1)

1215-1220: Fix operator precedence in CSS modules :local/:global ambiguity check

The condition currently parses as:

(this.options.css_modules != null and eql(name, "local")) or eql(name, "global")

so :global is treated as ambiguous even when css_modules is null. Both local and global should only be considered ambiguous when CSS modules are enabled. Group the name checks:

-                } else if (this.options.css_modules != null and bun.strings.eqlCaseInsensitiveASCII(name, "local") or bun.strings.eqlCaseInsensitiveASCII(name, "global")) {
+                } else if (this.options.css_modules != null and
+                    (bun.strings.eqlCaseInsensitiveASCII(name, "local") or
+                    bun.strings.eqlCaseInsensitiveASCII(name, "global")))
+                {
                     return .{ .err = loc.newCustomError(SelectorParseErrorKind{ .ambiguous_css_module_class = name }) };
                 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 006261237a4550324b39562bfa39dae5e7ed507e and 1bad8a4.

📒 Files selected for processing (48)
  • src/bun.js/api/crypto/EVP.zig (1 hunks)
  • src/bun.js/node/path.zig (1 hunks)
  • src/bun.js/uuid.zig (1 hunks)
  • src/bun.zig (4 hunks)
  • src/cli/create_command.zig (1 hunks)
  • src/cli/pack_command.zig (1 hunks)
  • src/cli/publish_command.zig (1 hunks)
  • src/css/css_parser.zig (11 hunks)
  • src/css/media_query.zig (2 hunks)
  • src/css/properties/animation.zig (2 hunks)
  • src/css/properties/background.zig (2 hunks)
  • src/css/properties/css_modules.zig (1 hunks)
  • src/css/properties/custom.zig (4 hunks)
  • src/css/properties/font.zig (1 hunks)
  • src/css/properties/generate_properties.ts (2 hunks)
  • src/css/properties/grid.zig (2 hunks)
  • src/css/properties/transform.zig (10 hunks)
  • src/css/rules/container.zig (1 hunks)
  • src/css/rules/font_face.zig (2 hunks)
  • src/css/rules/font_palette_values.zig (2 hunks)
  • src/css/rules/keyframes.zig (2 hunks)
  • src/css/rules/property.zig (1 hunks)
  • src/css/rules/supports.zig (2 hunks)
  • src/css/selectors/parser.zig (9 hunks)
  • src/css/targets.zig (1 hunks)
  • src/css/values/angle.zig (2 hunks)
  • src/css/values/color.zig (3 hunks)
  • src/css/values/easing.zig (2 hunks)
  • src/css/values/gradient.zig (3 hunks)
  • src/css/values/ident.zig (1 hunks)
  • src/css/values/image.zig (1 hunks)
  • src/css/values/length.zig (2 hunks)
  • src/css/values/resolution.zig (2 hunks)
  • src/css/values/syntax.zig (1 hunks)
  • src/css/values/time.zig (2 hunks)
  • src/deps/picohttp.zig (3 hunks)
  • src/http.zig (3 hunks)
  • src/http/Headers.zig (2 hunks)
  • src/http/websocket_client/WebSocketUpgradeClient.zig (6 hunks)
  • src/install/repository.zig (4 hunks)
  • src/options.zig (1 hunks)
  • src/output.zig (1 hunks)
  • src/resolver/resolve_path.zig (4 hunks)
  • src/sql/postgres/DataCell.zig (3 hunks)
  • src/string.zig (2 hunks)
  • src/string/immutable.zig (3 hunks)
  • src/url.zig (3 hunks)
  • src/which.zig (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
src/**/*.{cpp,zig}

📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)

src/**/*.{cpp,zig}: Use bun bd or bun run build:debug to build debug versions for C++ and Zig source files; creates debug build at ./build/debug/bun-debug
Run tests using bun bd test <test-file> with the debug build; never use bun test directly as it will not include your changes
Execute files using bun bd <file> <...args>; never use bun <file> directly as it will not include your changes
Enable debug logs for specific scopes using BUN_DEBUG_$(SCOPE)=1 environment variable
Code generation happens automatically as part of the build process; no manual code generation commands are required

Files:

  • src/css/values/image.zig
  • src/output.zig
  • src/css/values/angle.zig
  • src/css/properties/grid.zig
  • src/css/values/time.zig
  • src/css/rules/font_palette_values.zig
  • src/http/Headers.zig
  • src/css/values/easing.zig
  • src/install/repository.zig
  • src/css/media_query.zig
  • src/css/values/resolution.zig
  • src/css/properties/transform.zig
  • src/css/values/length.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/values/syntax.zig
  • src/css/rules/supports.zig
  • src/css/properties/font.zig
  • src/string.zig
  • src/css/rules/font_face.zig
  • src/cli/publish_command.zig
  • src/cli/pack_command.zig
  • src/http.zig
  • src/sql/postgres/DataCell.zig
  • src/css/targets.zig
  • src/css/rules/keyframes.zig
  • src/css/values/gradient.zig
  • src/options.zig
  • src/cli/create_command.zig
  • src/css/values/ident.zig
  • src/css/values/color.zig
  • src/css/properties/animation.zig
  • src/css/selectors/parser.zig
  • src/resolver/resolve_path.zig
  • src/bun.zig
  • src/css/properties/css_modules.zig
  • src/string/immutable.zig
  • src/deps/picohttp.zig
  • src/css/rules/container.zig
  • src/bun.js/node/path.zig
  • src/css/css_parser.zig
  • src/css/rules/property.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/url.zig
  • src/css/properties/custom.zig
  • src/css/properties/background.zig
  • src/bun.js/uuid.zig
  • src/which.zig
src/**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/building-bun.mdc)

Use bun.Output.scoped(.${SCOPE}, .hidden) for creating debug logs in Zig code

Implement core functionality in Zig, typically in its own directory in src/

src/**/*.zig: Zig source code should be organized in src/*.zig for core runtime, JavaScript bindings, and package manager
In Zig code, be careful with allocators and use defer for cleanup to manage memory properly
Use BUN_DEBUG_QUIET_LOGS=1 to disable debug logging, or BUN_DEBUG_<scopeName>=1 to enable specific Output.scoped calls in debug builds
Run bun run zig:check-all to compile the Zig code on all platforms when making platform-specific changes

src/**/*.zig: Private fields in Zig are fully supported using the # prefix: struct { #foo: u32 };
Use decl literals in Zig for declaration initialization: const decl: Decl = .{ .binding = 0, .value = 0 };
Prefer @import at the bottom of the file (auto formatter will move them automatically)

Files:

  • src/css/values/image.zig
  • src/output.zig
  • src/css/values/angle.zig
  • src/css/properties/grid.zig
  • src/css/values/time.zig
  • src/css/rules/font_palette_values.zig
  • src/http/Headers.zig
  • src/css/values/easing.zig
  • src/install/repository.zig
  • src/css/media_query.zig
  • src/css/values/resolution.zig
  • src/css/properties/transform.zig
  • src/css/values/length.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/values/syntax.zig
  • src/css/rules/supports.zig
  • src/css/properties/font.zig
  • src/string.zig
  • src/css/rules/font_face.zig
  • src/cli/publish_command.zig
  • src/cli/pack_command.zig
  • src/http.zig
  • src/sql/postgres/DataCell.zig
  • src/css/targets.zig
  • src/css/rules/keyframes.zig
  • src/css/values/gradient.zig
  • src/options.zig
  • src/cli/create_command.zig
  • src/css/values/ident.zig
  • src/css/values/color.zig
  • src/css/properties/animation.zig
  • src/css/selectors/parser.zig
  • src/resolver/resolve_path.zig
  • src/bun.zig
  • src/css/properties/css_modules.zig
  • src/string/immutable.zig
  • src/deps/picohttp.zig
  • src/css/rules/container.zig
  • src/bun.js/node/path.zig
  • src/css/css_parser.zig
  • src/css/rules/property.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/url.zig
  • src/css/properties/custom.zig
  • src/css/properties/background.zig
  • src/bun.js/uuid.zig
  • src/which.zig
**/*.zig

📄 CodeRabbit inference engine (.cursor/rules/zig-javascriptcore-classes.mdc)

**/*.zig: Expose generated bindings in Zig structs using pub const js = JSC.Codegen.JS<ClassName> with trait conversion methods: toJS, fromJS, and fromJSDirect
Use consistent parameter name globalObject instead of ctx in Zig constructor and method implementations
Use bun.JSError!JSValue return type for Zig methods and constructors to enable proper error handling and exception propagation
Implement resource cleanup using deinit() method that releases resources, followed by finalize() called by the GC that invokes deinit() and frees the pointer
Use JSC.markBinding(@src()) in finalize methods for debugging purposes before calling deinit()
For methods returning cached properties in Zig, declare external C++ functions using extern fn and callconv(JSC.conv) calling convention
Implement getter functions with naming pattern get<PropertyName> in Zig that accept this and globalObject parameters and return JSC.JSValue
Access JavaScript CallFrame arguments using callFrame.argument(i), check argument count with callFrame.argumentCount(), and get this with callFrame.thisValue()
For reference-counted objects, use .deref() in finalize instead of destroy() to release references to other JS objects

Files:

  • src/css/values/image.zig
  • src/output.zig
  • src/css/values/angle.zig
  • src/css/properties/grid.zig
  • src/css/values/time.zig
  • src/css/rules/font_palette_values.zig
  • src/http/Headers.zig
  • src/css/values/easing.zig
  • src/install/repository.zig
  • src/css/media_query.zig
  • src/css/values/resolution.zig
  • src/css/properties/transform.zig
  • src/css/values/length.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/values/syntax.zig
  • src/css/rules/supports.zig
  • src/css/properties/font.zig
  • src/string.zig
  • src/css/rules/font_face.zig
  • src/cli/publish_command.zig
  • src/cli/pack_command.zig
  • src/http.zig
  • src/sql/postgres/DataCell.zig
  • src/css/targets.zig
  • src/css/rules/keyframes.zig
  • src/css/values/gradient.zig
  • src/options.zig
  • src/cli/create_command.zig
  • src/css/values/ident.zig
  • src/css/values/color.zig
  • src/css/properties/animation.zig
  • src/css/selectors/parser.zig
  • src/resolver/resolve_path.zig
  • src/bun.zig
  • src/css/properties/css_modules.zig
  • src/string/immutable.zig
  • src/deps/picohttp.zig
  • src/css/rules/container.zig
  • src/bun.js/node/path.zig
  • src/css/css_parser.zig
  • src/css/rules/property.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/url.zig
  • src/css/properties/custom.zig
  • src/css/properties/background.zig
  • src/bun.js/uuid.zig
  • src/which.zig
src/**/*.{ts,zig,cpp}

📄 CodeRabbit inference engine (CLAUDE.md)

Always use absolute paths in file operations

Files:

  • src/css/values/image.zig
  • src/output.zig
  • src/css/values/angle.zig
  • src/css/properties/grid.zig
  • src/css/values/time.zig
  • src/css/rules/font_palette_values.zig
  • src/http/Headers.zig
  • src/css/values/easing.zig
  • src/install/repository.zig
  • src/css/media_query.zig
  • src/css/values/resolution.zig
  • src/css/properties/transform.zig
  • src/css/values/length.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/values/syntax.zig
  • src/css/rules/supports.zig
  • src/css/properties/font.zig
  • src/string.zig
  • src/css/rules/font_face.zig
  • src/cli/publish_command.zig
  • src/cli/pack_command.zig
  • src/http.zig
  • src/sql/postgres/DataCell.zig
  • src/css/targets.zig
  • src/css/rules/keyframes.zig
  • src/css/values/gradient.zig
  • src/options.zig
  • src/cli/create_command.zig
  • src/css/values/ident.zig
  • src/css/values/color.zig
  • src/css/properties/animation.zig
  • src/css/selectors/parser.zig
  • src/resolver/resolve_path.zig
  • src/bun.zig
  • src/css/properties/css_modules.zig
  • src/string/immutable.zig
  • src/deps/picohttp.zig
  • src/css/rules/container.zig
  • src/bun.js/node/path.zig
  • src/css/css_parser.zig
  • src/css/rules/property.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/url.zig
  • src/css/properties/custom.zig
  • src/css/properties/background.zig
  • src/css/properties/generate_properties.ts
  • src/bun.js/uuid.zig
  • src/which.zig
src/**/*.{ts,zig}

📄 CodeRabbit inference engine (CLAUDE.md)

Avoid shell commands in code - don't use find or grep; use Bun's Glob and built-in tools instead

Files:

  • src/css/values/image.zig
  • src/output.zig
  • src/css/values/angle.zig
  • src/css/properties/grid.zig
  • src/css/values/time.zig
  • src/css/rules/font_palette_values.zig
  • src/http/Headers.zig
  • src/css/values/easing.zig
  • src/install/repository.zig
  • src/css/media_query.zig
  • src/css/values/resolution.zig
  • src/css/properties/transform.zig
  • src/css/values/length.zig
  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/css/values/syntax.zig
  • src/css/rules/supports.zig
  • src/css/properties/font.zig
  • src/string.zig
  • src/css/rules/font_face.zig
  • src/cli/publish_command.zig
  • src/cli/pack_command.zig
  • src/http.zig
  • src/sql/postgres/DataCell.zig
  • src/css/targets.zig
  • src/css/rules/keyframes.zig
  • src/css/values/gradient.zig
  • src/options.zig
  • src/cli/create_command.zig
  • src/css/values/ident.zig
  • src/css/values/color.zig
  • src/css/properties/animation.zig
  • src/css/selectors/parser.zig
  • src/resolver/resolve_path.zig
  • src/bun.zig
  • src/css/properties/css_modules.zig
  • src/string/immutable.zig
  • src/deps/picohttp.zig
  • src/css/rules/container.zig
  • src/bun.js/node/path.zig
  • src/css/css_parser.zig
  • src/css/rules/property.zig
  • src/bun.js/api/crypto/EVP.zig
  • src/url.zig
  • src/css/properties/custom.zig
  • src/css/properties/background.zig
  • src/css/properties/generate_properties.ts
  • src/bun.js/uuid.zig
  • src/which.zig
🧠 Learnings (51)
📓 Common learnings
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 0
File: :0-0
Timestamp: 2025-09-02T19:17:26.376Z
Learning: In Bun's Zig codebase, when handling error unions where the same cleanup operation (like `rawFree`) needs to be performed regardless of success or failure, prefer using boolean folding with `else |err| switch (err)` over duplicating the cleanup call in multiple switch branches. This approach avoids code duplication while maintaining compile-time error checking.
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Applies to src/**/*.zig : Run `bun run zig:check-all` to compile the Zig code on all platforms when making platform-specific changes
Learnt from: RiskyMH
Repo: oven-sh/bun PR: 25111
File: packages/bun-types/wasm.d.ts:103-104
Timestamp: 2025-11-27T15:18:21.607Z
Learning: In the Bun repository, autofixci automatically formats code in the main branch, which can cause formatting diffs to appear in pull requests even when the PR author didn't make those changes. These formatting changes from autofixci are expected and not the PR author's responsibility.
Learnt from: fmguerreiro
Repo: oven-sh/bun PR: 23774
File: src/install/PackageManager/updatePackageJSONAndInstall.zig:548-548
Timestamp: 2025-10-24T10:43:09.398Z
Learning: In Bun's Zig codebase, the `as(usize, intCast(...))` cast pattern triggers a Zig compiler bug that causes compilation to hang indefinitely when used in complex control flow contexts (loops + short-circuit operators + optional unwrapping). Avoid this pattern and use simpler alternatives like just `intCast(...)` if type casting is necessary.
Learnt from: RiskyMH
Repo: oven-sh/bun PR: 22606
File: src/glob/GlobWalker.zig:449-452
Timestamp: 2025-09-12T18:16:50.754Z
Learning: For Bun codebase: prefer using `std.fs.path.sep` over manual platform separator detection, and use `bun.strings.lastIndexOfChar` instead of `std.mem.lastIndexOfScalar` for string operations.
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 24423
File: test/js/node/path/browserify.test.js:472-475
Timestamp: 2025-11-07T17:28:58.045Z
Learning: markovejnovic prefers functional programming patterns (e.g., using reduce) over imperative loops and does not want style-based readability suggestions unless there's a concrete technical reason beyond personal preference.
<!--
📚 Learning: 2025-11-12T07:15:00.763Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 24631
File: src/install/resolution.zig:375-376
Timestamp: 2025-11-12T07:15:00.763Z
Learning: In src/install/resolution.zig, the eql() function intentionally returns false for unknown/unhandled tags in the else branch, even though order() returns .eq for matching unknown tags. This semantic difference is by design.

Applied to files:

  • src/css/values/image.zig
  • src/css/values/angle.zig
  • src/install/repository.zig
  • src/css/media_query.zig
  • src/css/values/resolution.zig
  • src/css/properties/transform.zig
  • src/string.zig
  • src/sql/postgres/DataCell.zig
  • src/css/values/gradient.zig
  • src/css/values/ident.zig
  • src/css/selectors/parser.zig
  • src/string/immutable.zig
  • src/css/rules/container.zig
  • src/url.zig
📚 Learning: 2025-11-24T18:34:55.173Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/building-bun.mdc:0-0
Timestamp: 2025-11-24T18:34:55.173Z
Learning: Applies to src/**/*.zig : Use `bun.Output.scoped(.${SCOPE}, .hidden)` for creating debug logs in Zig code

Applied to files:

  • src/output.zig
📚 Learning: 2025-11-24T18:36:33.069Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Applies to src/**/*.zig : Use `BUN_DEBUG_QUIET_LOGS=1` to disable debug logging, or `BUN_DEBUG_<scopeName>=1` to enable specific Output.scoped calls in debug builds

Applied to files:

  • src/output.zig
📚 Learning: 2025-10-18T02:06:31.606Z
Learnt from: pfgithub
Repo: oven-sh/bun PR: 23796
File: src/bun.js/test/Execution.zig:624-625
Timestamp: 2025-10-18T02:06:31.606Z
Learning: In Zig files using bun.Output.scoped(), the visibility level `.visible` means logs are enabled by default in debug builds unless `BUN_DEBUG_QUIET_LOGS=1` is set; if that environment variable is set, the logs can be re-enabled with `BUN_DEBUG_<scope>=1`. Use `.visible` for logs that should appear by default in debug builds, and `.hidden` for logs that require explicit opt-in via `BUN_DEBUG_<scope>=1`.

Applied to files:

  • src/output.zig
📚 Learning: 2025-10-16T02:17:35.237Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/analytics.zig:15-21
Timestamp: 2025-10-16T02:17:35.237Z
Learning: In src/analytics.zig and similar files using bun.EnvVar boolean environment variables: the new EnvVar API for boolean flags (e.g., bun.EnvVar.do_not_track.get(), bun.EnvVar.ci.get()) is designed to parse and return boolean values from environment variables, not just check for their presence. This is an intentional design change from the previous presence-based checks using bun.getenvZ().

Applied to files:

  • src/output.zig
  • src/http/Headers.zig
  • src/css/media_query.zig
  • src/css/values/resolution.zig
  • src/css/values/syntax.zig
  • src/css/rules/supports.zig
  • src/css/rules/font_face.zig
  • src/css/targets.zig
  • src/css/values/ident.zig
  • src/css/values/color.zig
  • src/bun.zig
  • src/deps/picohttp.zig
  • src/bun.js/node/path.zig
  • src/css/css_parser.zig
  • src/url.zig
  • src/css/properties/custom.zig
  • src/bun.js/uuid.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to **/*.zig : Use consistent parameter name `globalObject` instead of `ctx` in Zig constructor and method implementations

Applied to files:

  • src/output.zig
  • src/css/values/angle.zig
  • src/css/properties/transform.zig
  • src/css/values/length.zig
  • src/css/selectors/parser.zig
  • src/bun.zig
  • src/deps/picohttp.zig
  • src/css/css_parser.zig
  • src/css/properties/custom.zig
📚 Learning: 2025-10-24T10:43:09.398Z
Learnt from: fmguerreiro
Repo: oven-sh/bun PR: 23774
File: src/install/PackageManager/updatePackageJSONAndInstall.zig:548-548
Timestamp: 2025-10-24T10:43:09.398Z
Learning: In Bun's Zig codebase, the `as(usize, intCast(...))` cast pattern triggers a Zig compiler bug that causes compilation to hang indefinitely when used in complex control flow contexts (loops + short-circuit operators + optional unwrapping). Avoid this pattern and use simpler alternatives like just `intCast(...)` if type casting is necessary.

Applied to files:

  • src/css/values/angle.zig
  • src/css/media_query.zig
  • src/css/values/resolution.zig
  • src/css/rules/supports.zig
  • src/string.zig
  • src/css/values/ident.zig
  • src/css/selectors/parser.zig
  • src/bun.zig
  • src/css/css_parser.zig
📚 Learning: 2025-09-06T03:37:41.154Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 22229
File: src/bundler/LinkerGraph.zig:0-0
Timestamp: 2025-09-06T03:37:41.154Z
Learning: In Bun's codebase, when checking import record source indices in src/bundler/LinkerGraph.zig, prefer using `if (import_index >= self.import_records.len)` bounds checking over `isValid()` checks, as the bounds check is more robust and `isValid()` is a strict subset of this condition.

Applied to files:

  • src/css/properties/grid.zig
  • src/css/values/resolution.zig
  • src/css/values/length.zig
  • src/css/rules/supports.zig
  • src/css/targets.zig
  • src/css/values/ident.zig
  • src/bun.zig
  • src/which.zig
📚 Learning: 2025-09-12T18:16:50.754Z
Learnt from: RiskyMH
Repo: oven-sh/bun PR: 22606
File: src/glob/GlobWalker.zig:449-452
Timestamp: 2025-09-12T18:16:50.754Z
Learning: For Bun codebase: prefer using `std.fs.path.sep` over manual platform separator detection, and use `bun.strings.lastIndexOfChar` instead of `std.mem.lastIndexOfScalar` for string operations.

Applied to files:

  • src/css/values/resolution.zig
  • src/css/rules/font_face.zig
  • src/css/selectors/parser.zig
  • src/resolver/resolve_path.zig
  • src/bun.zig
  • src/bun.js/node/path.zig
  • src/bun.js/uuid.zig
  • src/which.zig
📚 Learning: 2025-09-04T02:04:43.094Z
Learnt from: Jarred-Sumner
Repo: oven-sh/bun PR: 22278
File: src/ast/E.zig:980-1003
Timestamp: 2025-09-04T02:04:43.094Z
Learning: In Bun's Zig codebase, `as(i32, u8_or_u16_value)` is sufficient for casting u8/u16 to i32 in comparison operations. `intCast` is not required in this context, and the current casting approach compiles successfully.

Applied to files:

  • src/css/values/resolution.zig
  • src/string.zig
  • src/bun.zig
  • src/css/css_parser.zig
📚 Learning: 2025-10-18T20:50:47.750Z
Learnt from: theshadow27
Repo: oven-sh/bun PR: 23798
File: src/bun.js/telemetry.zig:366-373
Timestamp: 2025-10-18T20:50:47.750Z
Learning: In Bun's Zig codebase (src/bun.js/bindings/JSValue.zig), the JSValue enum uses `.null` (not `.js_null`) for JavaScript's null value. Only `js_undefined` has the `js_` prefix to avoid collision with Zig's built-in `undefined` keyword. The correct enum fields are: `js_undefined`, `null`, `true`, `false`, and `zero`.

Applied to files:

  • src/css/values/length.zig
  • src/css/values/syntax.zig
  • src/sql/postgres/DataCell.zig
  • src/css/targets.zig
  • src/css/values/ident.zig
  • src/css/values/color.zig
  • src/bun.js/node/path.zig
  • src/bun.js/uuid.zig
📚 Learning: 2025-10-01T21:59:54.571Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23169
File: src/bun.js/bindings/webcore/JSDOMConvertEnumeration.h:47-74
Timestamp: 2025-10-01T21:59:54.571Z
Learning: In the new bindings generator (bindgenv2) for `src/bun.js/bindings/webcore/JSDOMConvertEnumeration.h`, the context-aware enumeration conversion overloads intentionally use stricter validation (requiring `value.isString()` without ToString coercion), diverging from Web IDL semantics. This is a design decision documented in comments.

Applied to files:

  • src/css/values/length.zig
  • src/css/values/syntax.zig
  • src/css/rules/font_face.zig
  • src/css/values/ident.zig
  • src/css/values/color.zig
  • src/css/properties/custom.zig
  • src/bun.js/uuid.zig
📚 Learning: 2025-09-05T18:45:29.200Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 21728
File: src/valkey/js_valkey.zig:0-0
Timestamp: 2025-09-05T18:45:29.200Z
Learning: In JSValkeyClient.cloneWithoutConnecting() in src/valkey/js_valkey.zig, the address/username/password fields must be repointed to the duplicated connection_strings buffer to avoid use-after-free when the original client is destroyed. The original client properly frees connection_strings in ValkeyClient.deinit().

Applied to files:

  • src/http/websocket_client/WebSocketUpgradeClient.zig
📚 Learning: 2025-10-17T20:50:58.644Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23755
File: src/bun.js/api/bun/socket/Handlers.zig:154-159
Timestamp: 2025-10-17T20:50:58.644Z
Learning: In Bun socket configuration error messages (src/bun.js/api/bun/socket/Handlers.zig), use the user-facing JavaScript names "data" and "drain" instead of internal field names "onData" and "onWritable", as these are the names users see in the API according to SocketConfig.bindv2.ts.

Applied to files:

  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/bun.js/node/path.zig
  • src/bun.js/uuid.zig
📚 Learning: 2025-11-11T22:55:08.547Z
Learnt from: pfgithub
Repo: oven-sh/bun PR: 24571
File: src/css/values/url.zig:97-116
Timestamp: 2025-11-11T22:55:08.547Z
Learning: In Zig 0.15, the standard library module `std.io` was renamed to `std.Io` (with capital I). Code using `std.Io.Writer.Allocating` and similar types is correct for Zig 0.15+.

Applied to files:

  • src/http/websocket_client/WebSocketUpgradeClient.zig
  • src/string.zig
📚 Learning: 2025-09-02T18:25:27.976Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 22227
File: src/allocators/allocation_scope.zig:284-314
Timestamp: 2025-09-02T18:25:27.976Z
Learning: In bun's custom Zig implementation, the `#` prefix for private fields is valid syntax and should not be flagged as invalid. The syntax `#fieldname` creates private fields that cannot be accessed from outside the defining struct, and usage like `self.#fieldname` is correct within the same struct. This applies to fields like `#parent`, `#state`, `#allocator`, `#trace`, etc. throughout the codebase.

Applied to files:

  • src/css/values/syntax.zig
  • src/css/values/ident.zig
  • src/css/selectors/parser.zig
  • src/css/css_parser.zig
  • src/css/rules/property.zig
  • src/css/properties/custom.zig
📚 Learning: 2025-10-29T19:05:25.638Z
Learnt from: theshadow27
Repo: oven-sh/bun PR: 24063
File: packages/bun-types/telemetry.d.ts:252-261
Timestamp: 2025-10-29T19:05:25.638Z
Learning: In packages/bun-types/telemetry.d.ts and src/telemetry/telemetry.zig, the naming inconsistency between `kind` (public API) and `type` (internal implementation) is intentional. The public API uses `InstrumentInfo.kind: InstrumentKind` with string values ("http", "fetch", etc.) for developer ergonomics, while the internal implementation uses `InstrumentRecord.type: InstrumentType` with numeric enum (0-6) for O(1) dispatch performance. This dual naming provides both ergonomic strings externally and efficient numeric dispatch internally without compromising either developer experience or runtime performance.

Applied to files:

  • src/css/values/syntax.zig
📚 Learning: 2025-11-24T18:36:59.706Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:59.706Z
Learning: Applies to src/bun.js/bindings/v8/src/napi/napi.zig : For each new V8 C++ method, add both GCC/Clang and MSVC mangled symbol names to the V8API struct in src/napi/napi.zig using extern fn declarations

Applied to files:

  • src/css/values/syntax.zig
  • src/bun.js/node/path.zig
  • src/bun.js/uuid.zig
  • src/which.zig
📚 Learning: 2025-11-24T18:36:38.104Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:38.104Z
Learning: Applies to src/**/*.zig : Use decl literals in Zig for declaration initialization: `const decl: Decl = .{ .binding = 0, .value = 0 };`

Applied to files:

  • src/css/values/syntax.zig
📚 Learning: 2025-09-02T17:09:17.391Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 22227
File: src/allocators.zig:778-782
Timestamp: 2025-09-02T17:09:17.391Z
Learning: In Zig's bun codebase, the `isDefault` function in `src/allocators.zig` only needs to compare `allocator.vtable == c_allocator.vtable` rather than also checking the `ptr` field, because: (1) the codebase never creates multiple allocators that use `c_allocator.vtable` but have different `ptr`s, and (2) the default allocator vtable ignores the `ptr` field anyway, so any allocators sharing the same vtable would function identically.

Applied to files:

  • src/string.zig
  • src/css/targets.zig
  • src/css/values/ident.zig
  • src/bun.zig
  • src/deps/picohttp.zig
  • src/css/css_parser.zig
📚 Learning: 2025-09-25T22:51:15.539Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 22946
File: src/js/internal/sql/postgres.ts:138-143
Timestamp: 2025-09-25T22:51:15.539Z
Learning: In PostgreSQL array serialization for Bun.SQL, typed arrays (Uint8Array, Int32Array, etc.) should always be treated as arrays and expand their elements, not as binary data. BYTEA binary serialization should only use Buffer objects, maintaining consistency with postgres.js behavior. Typed arrays and Buffer have different semantic purposes.

Applied to files:

  • src/sql/postgres/DataCell.zig
📚 Learning: 2025-09-25T01:02:43.263Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 22946
File: src/js/internal/sql/postgres.ts:188-198
Timestamp: 2025-09-25T01:02:43.263Z
Learning: In the PostgreSQL array implementation for Bun.SQL, when getPostgresArrayType returns null for unknown numeric OIDs, throwing an error is not the desired behavior. The user prefers a different approach for handling unknown array type OIDs.

Applied to files:

  • src/sql/postgres/DataCell.zig
📚 Learning: 2025-09-25T01:04:19.262Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 22946
File: src/js/internal/sql/postgres.ts:1185-1416
Timestamp: 2025-09-25T01:04:19.262Z
Learning: In the PostgreSQL array implementation for Bun.SQL, when serializing arrays for JSON/JSONB columns, the user prefers using PostgreSQL array literal format (serializeArray(value, "JSON")) over standard JSON serialization (JSON.stringify(value)). PostgreSQL JSON array handling is different from JavaScript JSON array handling according to the user's requirements.

Applied to files:

  • src/sql/postgres/DataCell.zig
📚 Learning: 2025-10-01T21:49:27.862Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23169
File: src/bun.js/bindings/BunIDLConvert.h:29-42
Timestamp: 2025-10-01T21:49:27.862Z
Learning: In Bun's IDL bindings (src/bun.js/bindings/BunIDLConvert.h), IDLStrictNull intentionally treats both undefined and null as null (using isUndefinedOrNull()), matching WebKit's IDLNull & IDLNullable behavior. This is the correct implementation and should not be changed to only accept null.

Applied to files:

  • src/css/targets.zig
📚 Learning: 2025-11-11T22:55:04.070Z
Learnt from: pfgithub
Repo: oven-sh/bun PR: 24571
File: src/css/selectors/parser.zig:908-916
Timestamp: 2025-11-11T22:55:04.070Z
Learning: In oven-sh/bun, CSS serialization uses an arena allocator. In src/css/selectors/parser.zig, functions like PseudoClass.toCss and PseudoElement.toCss intentionally do not call deinit on std.Io.Writer.Allocating, scratch buffers, or css.Printer because dest.allocator is an arena and these temporaries are reclaimed when the CSS pass completes. Only debug-only paths (e.g., DeclarationBlock.DebugFmt in src/css/declaration.zig) may explicitly deinit.

Applied to files:

  • src/css/rules/keyframes.zig
  • src/css/properties/animation.zig
  • src/css/selectors/parser.zig
  • src/css/properties/css_modules.zig
  • src/css/properties/custom.zig
  • src/css/properties/generate_properties.ts
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Applies to **/js_*.zig : Use `bun.JSError!JSValue` for proper error propagation in JavaScript bindings

Applied to files:

  • src/css/values/ident.zig
  • src/css/properties/css_modules.zig
  • src/css/properties/generate_properties.ts
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to **/*.zig : Use `bun.JSError!JSValue` return type for Zig methods and constructors to enable proper error handling and exception propagation

Applied to files:

  • src/css/values/ident.zig
  • src/css/properties/generate_properties.ts
📚 Learning: 2025-10-30T21:52:04.707Z
Learnt from: pfgithub
Repo: oven-sh/bun PR: 24212
File: src/cli/publish_command.zig:782-788
Timestamp: 2025-10-30T21:52:04.707Z
Learning: In the Bun codebase (oven-sh/bun), `enable_ansi_colors` flags are used to gate both ANSI color codes and Unicode box-drawing characters/emoji. This is the established pattern across the codebase.

Applied to files:

  • src/css/values/color.zig
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Applies to **/*js_bindings.classes.ts : Use `JSC.Codegen` correctly to generate necessary binding code for JavaScript-Zig integration

Applied to files:

  • src/css/selectors/parser.zig
  • src/css/properties/generate_properties.ts
📚 Learning: 2025-11-24T18:36:33.069Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Applies to src/bun.js/bindings/**/*.cpp : When implementing JavaScript classes in C++, define properties using HashTableValue arrays and add iso subspaces for classes with C++ fields, caching structures in ZigGlobalObject

Applied to files:

  • src/css/selectors/parser.zig
  • src/bun.js/uuid.zig
📚 Learning: 2025-11-24T18:37:47.899Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/AGENTS.md:0-0
Timestamp: 2025-11-24T18:37:47.899Z
Learning: Applies to src/bun.js/bindings/v8/**/<UNKNOWN> : <UNKNOWN>

Applied to files:

  • src/css/selectors/parser.zig
📚 Learning: 2025-11-24T18:36:33.069Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Applies to src/**/*.{ts,zig,cpp} : Always use absolute paths in file operations

Applied to files:

  • src/resolver/resolve_path.zig
📚 Learning: 2025-10-08T13:56:00.875Z
Learnt from: Jarred-Sumner
Repo: oven-sh/bun PR: 23373
File: src/bun.js/api/BunObject.zig:2514-2521
Timestamp: 2025-10-08T13:56:00.875Z
Learning: For Bun codebase: prefer using `bun.path` utilities (e.g., `bun.path.joinAbsStringBuf`, `bun.path.join`) over `std.fs.path` functions for path operations.

Applied to files:

  • src/resolver/resolve_path.zig
  • src/bun.js/node/path.zig
📚 Learning: 2025-10-21T20:57:01.892Z
Learnt from: taylordotfish
Repo: oven-sh/bun PR: 23889
File: src/string.zig:751-752
Timestamp: 2025-10-21T20:57:01.892Z
Learning: In Zig code handling bun.String: calling deref() on an empty bun.String (String.empty or after being set to .empty) is well-defined behavior and safely does nothing (no-op). While such calls may be redundant and could be removed for code clarity, their presence is not a correctness issue.

Applied to files:

  • src/bun.zig
📚 Learning: 2025-11-24T18:36:33.069Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Applies to src/**/*.zig : Run `bun run zig:check-all` to compile the Zig code on all platforms when making platform-specific changes

Applied to files:

  • src/bun.zig
  • src/which.zig
📚 Learning: 2025-10-16T17:32:03.074Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/install/PackageManager/PackageManagerOptions.zig:187-193
Timestamp: 2025-10-16T17:32:03.074Z
Learning: In Bun's codebase (particularly in files like src/install/PackageManager/PackageManagerOptions.zig), mixing bun.EnvVar.*.get() and bun.EnvVar.*.platformGet() for environment variable lookups is intentional and safe. The code is protected by compile-time platform checks (Environment.isWindows, etc.), and compilation will fail if the wrong function is used on the wrong platform. This pattern should not be flagged as a consistency issue.

Applied to files:

  • src/bun.zig
📚 Learning: 2025-11-24T18:35:08.612Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/dev-server-tests.mdc:0-0
Timestamp: 2025-11-24T18:35:08.612Z
Learning: Applies to test/bake/dev/css.test.ts : Organize CSS tests in css.test.ts for tests concerning bundling bugs with CSS files

Applied to files:

  • src/css/properties/css_modules.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to **/*.zig : Expose generated bindings in Zig structs using `pub const js = JSC.Codegen.JS<ClassName>` with trait conversion methods: `toJS`, `fromJS`, and `fromJSDirect`

Applied to files:

  • src/css/properties/css_modules.zig
📚 Learning: 2025-11-24T18:36:38.104Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:38.104Z
Learning: Applies to src/**/*.zig : Prefer `import` at the bottom of the file (auto formatter will move them automatically)

Applied to files:

  • src/css/properties/css_modules.zig
📚 Learning: 2025-11-24T18:36:08.558Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/zig-javascriptcore-classes.mdc:0-0
Timestamp: 2025-11-24T18:36:08.558Z
Learning: Applies to src/bun.js/bindings/generated_classes_list.zig : Include new class bindings in `src/bun.js/bindings/generated_classes_list.zig` to register them with the code generator

Applied to files:

  • src/css/properties/css_modules.zig
  • src/bun.js/node/path.zig
  • src/bun.js/uuid.zig
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Applies to src/bun.js/api/BunObject.zig : Implement getter functions in `src/bun.js/api/BunObject.zig` that return your feature, and export them in the `exportAll()` function

Applied to files:

  • src/bun.js/node/path.zig
  • src/bun.js/uuid.zig
📚 Learning: 2025-11-24T18:36:59.706Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/bun.js/bindings/v8/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:59.706Z
Learning: Applies to src/bun.js/bindings/v8/test/v8/v8.test.ts : Add corresponding test cases to test/v8/v8.test.ts using checkSameOutput() function to compare Node.js and Bun output

Applied to files:

  • src/bun.js/node/path.zig
  • src/bun.js/uuid.zig
📚 Learning: 2025-11-12T04:11:52.293Z
Learnt from: cirospaciari
Repo: oven-sh/bun PR: 24622
File: src/deps/uws/us_socket_t.zig:112-113
Timestamp: 2025-11-12T04:11:52.293Z
Learning: In Bun's Zig codebase, when passing u32 values to C FFI functions that expect c_uint parameters, no explicit intCast is needed because c_uint is equivalent to u32 on Bun's target platforms and Zig allows implicit coercion between equivalent types. This pattern is used consistently throughout src/deps/uws/us_socket_t.zig in functions like setTimeout, setLongTimeout, and setKeepalive.

Applied to files:

  • src/bun.js/node/path.zig
📚 Learning: 2025-09-25T18:39:03.607Z
Learnt from: nektro
Repo: oven-sh/bun PR: 22958
File: src/bun.js/api/crypto/EVP.zig:24-24
Timestamp: 2025-09-25T18:39:03.607Z
Learning: BoringSSL's translated bindings in src/deps/boringssl.translated.zig only provide EVP_blake2b256() and EVP_blake2b512() extern function declarations. EVP_blake2s256() does not exist in BoringSSL bindings, so blake2s256 algorithm support must rely on the EVP_get_digestbyname() fallback mechanism rather than direct function binding in the Algorithm.md() switch statement.

Applied to files:

  • src/bun.js/api/crypto/EVP.zig
📚 Learning: 2025-09-25T18:39:03.607Z
Learnt from: nektro
Repo: oven-sh/bun PR: 22958
File: src/bun.js/api/crypto/EVP.zig:24-24
Timestamp: 2025-09-25T18:39:03.607Z
Learning: BoringSSL does not provide EVP_blake2s256() function binding in Bun's codebase, unlike EVP_blake2b256() and EVP_blake2b512() which are available. For blake2s256 algorithm support, the correct approach is to rely on the EVP_get_digestbyname() fallback mechanism rather than adding a direct function binding to the Algorithm.md() switch statement.

Applied to files:

  • src/bun.js/api/crypto/EVP.zig
📚 Learning: 2025-11-24T18:36:38.104Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: src/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:38.104Z
Learning: Applies to src/**/*.zig : Private fields in Zig are fully supported using the `#` prefix: `struct { #foo: u32 };`

Applied to files:

  • src/url.zig
📚 Learning: 2025-10-15T22:03:50.832Z
Learnt from: markovejnovic
Repo: oven-sh/bun PR: 23710
File: src/envvars.zig:135-144
Timestamp: 2025-10-15T22:03:50.832Z
Learning: In src/envvars.zig, the boolean feature flag cache uses a single atomic enum and should remain monotonic. Only the string cache (which uses two atomics: ptr and len) requires acquire/release ordering to prevent torn reads.

Applied to files:

  • src/url.zig
📚 Learning: 2025-11-24T18:35:39.205Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: .cursor/rules/registering-bun-modules.mdc:0-0
Timestamp: 2025-11-24T18:35:39.205Z
Learning: Applies to **/*js_bindings.classes.ts : Add JSDoc comments to JavaScript binding definitions in `.classes.ts` files

Applied to files:

  • src/css/properties/generate_properties.ts
📚 Learning: 2025-11-24T18:36:33.069Z
Learnt from: CR
Repo: oven-sh/bun PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T18:36:33.069Z
Learning: Generated code files are auto-generated from `.classes.ts` and other sources - Bun will automatically rebuild these files when you make changes to source files

Applied to files:

  • src/css/properties/generate_properties.ts
📚 Learning: 2025-10-13T06:54:58.043Z
Learnt from: robobun
Repo: oven-sh/bun PR: 0
File: :0-0
Timestamp: 2025-10-13T06:54:58.043Z
Learning: File extensions in Bun's module resolution are case-sensitive by design, and there are no existing precedents in the codebase for case-insensitive HTML file detection.

Applied to files:

  • src/which.zig

Comment thread src/bun.js/node/path.zig
Comment on lines 20 to 24
fn eqlIgnoreCaseT(comptime T: type, a: []const T, b: []const T) bool {
if (T != u16) {
return bun.strings.eqlCaseInsensitiveASCII(a, b, true);
return bun.strings.eqlCaseInsensitiveASCII(a, b);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Function is incomplete for T == u16.

The eqlIgnoreCaseT function only handles the T != u16 case. When T == u16, there's no return statement, which would cause a compile error if this code path were instantiated. However, tracing the call sites shows this function is only called with T = u8 in practice (via relative(), resolve(), etc.), so Zig never compiles the u16 branch.

For consistency with toLowerT (which handles both cases), consider either:

  1. Adding the u16 implementation, or
  2. Adding a @compileError for the u16 case to make the limitation explicit

This is a pre-existing issue, not introduced by this PR's migration to the unified API.

 fn eqlIgnoreCaseT(comptime T: type, a: []const T, b: []const T) bool {
     if (T != u16) {
         return bun.strings.eqlCaseInsensitiveASCII(a, b);
     }
+    if (a.len != b.len) return false;
+    for (a, b) |a_c, b_c| {
+        const a_lower: T = if (a_c < 128) @intCast(std.ascii.toLower(@intCast(a_c))) else a_c;
+        const b_lower: T = if (b_c < 128) @intCast(std.ascii.toLower(@intCast(b_c))) else b_c;
+        if (a_lower != b_lower) return false;
+    }
+    return true;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fn eqlIgnoreCaseT(comptime T: type, a: []const T, b: []const T) bool {
if (T != u16) {
return bun.strings.eqlCaseInsensitiveASCII(a, b, true);
return bun.strings.eqlCaseInsensitiveASCII(a, b);
}
}
fn eqlIgnoreCaseT(comptime T: type, a: []const T, b: []const T) bool {
if (T != u16) {
return bun.strings.eqlCaseInsensitiveASCII(a, b);
}
if (a.len != b.len) return false;
for (a, b) |a_c, b_c| {
const a_lower: T = if (a_c < 128) @intCast(std.ascii.toLower(@intCast(a_c))) else a_c;
const b_lower: T = if (b_c < 128) @intCast(std.ascii.toLower(@intCast(b_c))) else b_c;
if (a_lower != b_lower) return false;
}
return true;
}

Comment on lines +111 to +117
if (bun.strings.eqlCaseInsensitiveASCII(s, "none") or
bun.strings.eqlCaseInsensitiveASCII(s, "initial") or
bun.strings.eqlCaseInsensitiveASCII(s, "inherit") or
bun.strings.eqlCaseInsensitiveASCII(s, "unset") or
bun.strings.eqlCaseInsensitiveASCII(s, "default") or
bun.strings.eqlCaseInsensitiveASCII(s, "revert") or
bun.strings.eqlCaseInsensitiveASCII(s, "revert-layer"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Confirm eqlCaseInsensitiveASCII remains a full, length-respecting equality check

The replacements to bun.strings.eqlCaseInsensitiveASCII(s, "...") in both KeyframesName.parse and KeyframesName.toCss look mechanically correct, assuming the unified helper still enforces equal lengths and compares the entire string. If, instead, it only checks a prefix of s, identifiers like "noneX" or "initially" could start being treated as CSS-wide keywords, which would be a subtle behavior change.

Two follow-ups I’d recommend:

  1. Verify helper semantics / tests

    • Ensure eqlCaseInsensitiveASCII guarantees same-length, full-string ASCII case-insensitive equality.
    • If not already covered, consider tests that assert:
      • eqlCaseInsensitiveASCII("none", "NoNe") == true
      • eqlCaseInsensitiveASCII("noneX", "none") == false
      • Similar for "initial", "inherit", "unset", "default", "revert", "revert-layer".
  2. (Optional) Factor keyword check into a shared helper
    Both branches now duplicate the same chain of checks. A small local helper like isKeyframesCssWideKeywordIgnoreCase(s: []const u8) bool reused in parse and toCss would keep the keyword list single-sourced and reduce the chance of them diverging if new CSS-wide keywords need to be handled later.

Also applies to: 141-147

🤖 Prompt for AI Agents
In src/css/rules/keyframes.zig around lines 111-117 (and similarly 141-147), the
replacement calls to bun.strings.eqlCaseInsensitiveASCII must be confirmed to
perform full-length, whole-string ASCII case-insensitive equality (not
prefix-only); verify the helper's semantics and, if it currently allows prefix
matches, update it so it checks lengths and full contents. Add unit tests
asserting true for eqlCaseInsensitiveASCII("none","NoNe") and false for
eqlCaseInsensitiveASCII("noneX","none") (and equivalent tests for
"initial","inherit","unset","default","revert","revert-layer"). Also optionally
factor the repeated keyword chain into a single helper (e.g.,
isKeyframesCssWideKeywordIgnoreCase(s: []const u8) bool) and use it in both
KeyframesName.parse and KeyframesName.toCss to avoid duplication.

Comment thread src/string/immutable.zig
Comment on lines +973 to +974
/// Note that this function performs bound checks, but is marked as inline, so the caller may also
/// perform bounds checks without a performance penalty.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this comment apply considering std.ascii.eqlIgnoreCase is not marked inline?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just replace all uses of eqlCaseInsensitiveASCII with std.ascii.eqlIgnoreCase?

@robobun

robobun commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Closing as stale: this PR predates the Rust rewrite. Every src/ file it modifies has since been removed or relocated on main (Zig sources deleted; src/bun.js/ reorganized into src/jsc/), so it can no longer merge.

If the underlying change is still wanted, it will need to be redone against the current Rust/C++ tree. Apologies for the churn, and thank you for the contribution.

@robobun robobun closed this Jun 26, 2026
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.

3 participants