Skip to content

fix(napi-derive): panic while creating type definition when Rust comment contains escape syntax - #2701

Merged
Brooooooklyn merged 1 commit into
mainfrom
06-08-fix_napi-derive_panic_while_creating_type_definition_when_rust_comment_contains_escape_syntax
Jun 8, 2025
Merged

Brooooooklyn merged 1 commit into
mainfrom
06-08-fix_napi-derive_panic_while_creating_type_definition_when_rust_comment_contains_escape_syntax

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Jun 8, 2025 •

Copy link
Copy Markdown
Member

Brooooooklyn commented Jun 8, 2025 •

Copy link
Copy Markdown
Member Author

@Brooooooklyn

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Unintended Newline Replacement in Documentation

The replace(/\\n/g, '\n') operation unconditionally replaces literal \n sequences with actual newlines in js_doc and def fields. This incorrectly transforms instances where developers intend to display the literal text \n in documentation comments or type definitions, rather than an actual newline.

cli/src/utils/typegen.ts#L145-L154

// Convert escaped newlines back to actual newlines in js_doc fields
if (parsed.js_doc) {
parsed.js_doc = parsed.js_doc.replace(/\\n/g, '\n')
}
// Convert escaped newlines to actual newlines in def fields for struct/class/interface/type types
// where \n represents method/field separators that should be actual newlines
if (parsed.def) {
parsed.def = parsed.def.replace(/\\n/g, '\n')
}
return parsed

Fix in Cursor


BugBot free trial expires on June 14, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

@Brooooooklyn
Brooooooklyn merged commit 54935e3 into main Jun 8, 2025
@Brooooooklyn
Brooooooklyn deleted the 06-08-fix_napi-derive_panic_while_creating_type_definition_when_rust_comment_contains_escape_syntax branch June 8, 2025 10:25
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.

JSON parse fails while creating type definition when Rust comment contains escape syntax

1 participant