fix: chalk boolean style modifiers — <Text dimColor> no longer renders [object Object] (#5039)#5045
Merged
Merged
Conversation
This was referenced Jun 12, 2026
Closed
added 2 commits
June 12, 2026 20:56
…nex B misroute, subpath imports, template escapes
c76b100 to
e62a73b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5039 — ink
<Text dimColor>rendered[object Object]instead of its text.chalk 5's style modifiers are getter accessors on a function prototype chain (
Object.defineProperties(createChalk.prototype, styles), reached viaObject.setPrototypeOf(chalk, createChalk.prototype)wherechalkis itself a function). Four independent gaps conspired sochalk.dimnever resolved; the issue's "boolean modifier vs string color" framing turned out to be a red herring —color="cyan"only looked fine because broken chalk made ink fall back to the unstyled string.The four fixes
runtime —
closure/dynamic_props.rs:closure_get_dynamic_prop's static-prototype walk only consulted data properties. Both arms (closure proto and plain-object proto) now resolve accessor descriptors, invoking the getter with the original receiver (clone_closure_rebind_this), so chalk'sObject.defineProperty(this, styleName, {value: builder})self-cache lands on the instance instead of throwingCannot redefine property: dimagainst the non-configurable accessor on the shared proto.codegen —
lower_call/property_get.rs: Annex B HTML-wrapper names (bold,link,anchor,big, …) on any-typed receivers were force-routed toString.prototype, sochalk.bold(s)coerced the chalk closure to its source text and returned<b>(...strings) => strings.join(' ')</b>. Dropped them from the force list; an Any receiver that really is a string still resolves through thejsval.is_string()arm ofjs_native_call_method(covered in the gap test).resolver —
commands/compile/resolve.rs: Node subpath imports (#-prefixed specifiers via the package's ownpackage.json"imports"map) were unsupported, so chalk'simport ansiStyles from '#ansi-styles'(vendored dep) silently resolved to nothing and every style table came up empty. Reuses the exports-conditions resolver withnoderanked abovedefault(chalk's#supports-colorships a browser build asdefault). Per Node's package-scope rule only the nearestpackage.jsonis consulted.HIR —
lower_patterns.rs:unescape_templatedidn't decode\xHH/\uHHHH/\u{…}(nor\b \f \v \0, line continuations), so ansi-styles'`\^[[${code}m`template literals produced 6 literal chars instead of ESC. Surrogate pairs combine; a lone surrogate becomes U+FFFD (WTF-8 stays a categorical gap).Validation
test-files/test_gap_chalk_proto_styles_5039.ts— byte-identical vsnode --experimental-strip-types(chalk's exact proto shape incl. the defineProperty self-cache, nestedchalk.dim.bold, Annex B-on-string behavior, template escapes).perry.compilePackagesproduces Node-identical ANSI output fordim/bold/cyan.cyannow emits real escapes too — previously it silently rendered unstyled.)cargo test --releasefor perry-hir / perry-codegen / perry-runtime / perry: green (issue_4908_subclass_native_member_basefailed once under full-suite load, passes in isolation — known load artifact).a46ca1dd6(pre-fix main) — 46 fail identically there, and the 47th (test_issue_2131_net_lifecycle_edge) is the documented load flake (passes 100% idle on this branch).Deferred (pre-existing, observed while validating)
Object.entries(o)includes non-enumerabledefinePropertyslots (Object.keysis correct):Object.defineProperty(o,'hidden',{value:1}); o.shown=2→ Perry[["hidden",1],["shown",2]], Node[["shown",2]]. Observed as ansi-styles enumerating 55 entries vs Node's 45 — harmless for chalk (extra unused getters).JSON.stringifyemits the 4-hex-digit unicode escapes for U+000C/U+0008 instead of the\f/\bshort forms — filed as JSON.stringify emits \u000c/\u0008 instead of the \f/\b short forms #5047. (TheObject.entriesfinding above is Object.entries/values include non-enumerable defineProperty slots (Object.keys is correct) #5046.)Rebased onto main after #5038/#5040/#5043/#5041 landed; this PR is v0.5.1163.