Skip to content

jsc: name the line:column flag at source_url_formatter call sites - #39152

Merged
alii merged 1 commit into
mainfrom
farm/833147c4/source-url-formatter-line-column
Aug 15, 2026
Merged

jsc: name the line:column flag at source_url_formatter call sites#39152
alii merged 1 commit into
mainfrom
farm/833147c4/source-url-formatter-line-column

Conversation

@robobun

@robobun robobun commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

  • ZigStackFrame::source_url_formatter (src/jsc/ZigStackFrame.rs) takes two bools, exclude_line_column and enable_color. Two callers pass literals for both: source_url_formatter(root_path, origin, true, false) in snapshot() and (file, origin, false, false) in print_github_annotation. Nothing at those calls says which flag is which, and the swapped call compiles.
  • This is the "bare_bool_args:src/jsc/ZigStackFrame.rs" entry in mordant-baseline.toml.

Fix

  • exclude_line_column: bool becomes line_column: LineColumn, a two-variant enum (Include / Exclude) next to SourceURLFormatter, so every call names it. The two Display conditions that read the flag are the only other code change.
  • enable_color stays a bool: the print_stack_trace callers forward a runtime allow_ansi_colors, and name_formatter on the same lines takes the same bool. With one bool left in the signature there is nothing to confuse it with, which is also what makes the lint quiet. Same shape as ErrorDisplayLevel::formatter(name, enable_colors: bool, colon: Colon) in ConsoleObject.rs.
  • The baseline line is removed. With the line removed, cargo dylint --all -- -p bun_jsc on main's source reports exactly this finding (bun_jsc 1 in target/mordant/over-baseline.txt); on this branch it reports nothing. Regenerating in write mode scoped to bun_jsc and the crates it pulls in reproduces the file byte for byte apart from this line and one unrelated entry that is already stale on main (always_unwrapped_option:src/install/PackageInstall.rs), which this PR leaves alone.
  • No new test: there is no behavior to pin that the existing tests below do not already pin, and a test cannot tell the enum from the bool. The guard against this site regressing is the baseline removal itself: with no count recorded for this file, the mordant job reports any bare_bool_args finding in it from now on.
  • No output change:
    • bun bd test test/js/bun/http/serve.test.ts -t "dev error page" (the Exclude caller: the page's frames[].file must not carry :line:col), test/cli/test/bun-test.test.ts -t "Github Actions" (the annotation caller), test/js/bun/util/reportError.test.ts, error-name-preservation.test.ts, test/regression/issue/{23649,11793,12782}.test.ts: pass.
    • An uncaught error printed by this build and by the release bun gives byte-identical frame lines with NO_COLOR, with FORCE_COLOR=1 (the dimmed cwd prefix path) and as a GITHUB_ACTIONS annotation.
    • test/js/bun/util/inspect-error.test.js has two snapshot failures under a debug build that reproduce identically on an unmodified checkout (a debug-only at require (51:24) frame its filter does not strip); tracked separately.

Background

  • SourceURLFormatter is the Display type behind every at name (file:line:col) stack frame line Bun prints: terminal error output, the ::error annotation under GitHub Actions, and the Bun.serve development error page. The error page stores the position separately and wants only the file, which is the one Exclude use.
  • mordant is the Rust lint pack behind the advisory mordant job in rust-lints.yml. mordant-baseline.toml records, per lint and file, how many findings predate the job; the job fails only on findings above the recorded count, so fixing one means deleting its line so the count cannot creep back.

source_url_formatter took two bools (exclude_line_column, enable_color)
and two of its callers passed literals for both, so a call read as
source_url_formatter(.., true, false) with nothing saying which was
which. The line:column flag is now a two-variant enum, LineColumn, so
each call names it. enable_color stays a bool: most callers forward a
runtime allow_ansi_colors, and name_formatter beside it takes the same
bool. Same shape as Colon::{IncludeColon, ExcludeColon} in
ConsoleObject.rs.

Output is unchanged. Drops the matching bare_bool_args entry from
mordant-baseline.toml.
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@robobun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0dac1ce2-46fd-4afc-b779-90d75005f00f

📥 Commits

Reviewing files that changed from the base of the PR and between bcab5ed and f63cad7.

📒 Files selected for processing (3)
  • mordant-baseline.toml
  • src/jsc/VirtualMachine.rs
  • src/jsc/ZigStackFrame.rs

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

@robobun

robobun commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author
Updated 12:05 PM PT - Aug 15th, 2026

@robobun, your commit f63cad7 has some failures in Build #98402 (All Failures)


🧪   To try this PR locally:

bunx bun-pr 39152

That installs a local version of the PR into your bun-39152 executable, so you can run:

bun-39152 --bun

@claude claude 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.

LGTM — mechanical bool→enum refactor with no behavior change.

What was reviewed:

  • All 5 source_url_formatter call sites map to the correct LineColumn variant (polarity of the old exclude_line_column bool preserved); no other callers or direct SourceURLFormatter constructions exist in the tree.
  • The two Display conditions flip !self.exclude_line_column== LineColumn::Include, which is equivalent.
  • crate::zig_stack_frame::LineColumn resolves via the pub mod zig_stack_frame in src/jsc/lib.rs, and pub(crate) visibility is sufficient for the VirtualMachine.rs callers.
Extended reasoning...

Overview

This PR replaces the exclude_line_column: bool parameter of ZigStackFrame::source_url_formatter with a two-variant LineColumn enum (Include / Exclude), updates the corresponding SourceURLFormatter struct field, flips the two conditions in its Display impl, updates all five call sites (four in VirtualMachine.rs, one in ZigStackFrame.rs), and removes the corresponding bare_bool_args entry from mordant-baseline.toml. The remaining enable_color: bool parameter is left as-is since it's forwarded from a runtime value and no longer sits next to another bool literal.

Security risks

None. This is a type-level refactor of an internal formatting helper for stack-trace output; no parsing, no I/O, no external input handling changes.

Level of scrutiny

Low. The change is small, mechanical, and type-checked by the compiler — a missed call site or wrong argument type would fail to compile. The only thing to verify by hand is polarity, and each of the five sites maps correctly: the four callers that previously passed false (don't exclude) now pass LineColumn::Include, and the one snapshot() caller that passed true now passes LineColumn::Exclude. The two Display conditions !self.exclude_line_column become self.line_column == LineColumn::Include, which is semantically identical.

Other factors

Grep confirms there are no other references to source_url_formatter, SourceURLFormatter, or exclude_line_column in the tree, so nothing was missed. The use crate::zig_stack_frame::LineColumn import path is valid (pub mod zig_stack_frame at src/jsc/lib.rs:460) and the pub(crate) visibility on the enum is sufficient for both callers, which are in the same crate. The PR description documents byte-identical output verification against the release binary and passing tests for each caller (dev error page, GitHub annotation, reportError). The baseline removal is scoped to exactly the entry being fixed.

@github-actions

Copy link
Copy Markdown
Contributor

This PR may be a duplicate of:

  1. Replace boolean flag parameters with two-variant enums #37180 - Makes the same exclude_line_column: bool → two-variant enum change to ZigStackFrame::source_url_formatter (and the same snapshot() / print_stack_trace / print_github_annotation call sites), as part of a workspace-wide bool-flag-to-enum sweep.

🤖 Generated with Claude Code

@robobun

robobun commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator Author

The overlap with #37180 is this one call site. That PR retypes the flag (and enable_color) through a bool_enum! macro and an AnsiColors type it adds to bun_core, as one hunk of a 539-file sweep that currently needs a rebase, so the hunk does not apply on its own. This PR clears the one mordant baseline entry with what is already on main (the same shape as Colon in ConsoleObject.rs) and is independent of it. If #37180 lands first this can be closed; if this lands first it is one more small hunk for that rebase.

@alii
alii merged commit 8a09cf7 into main Aug 15, 2026
12 of 14 checks passed
@alii
alii deleted the farm/833147c4/source-url-formatter-line-column branch August 15, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants