Skip to content

Fix undefined indentation when exactly 64 indents#17774

Merged
nicolo-ribaudo merged 1 commit intobabel:mainfrom
YoussefHenna:main
Feb 3, 2026
Merged

Fix undefined indentation when exactly 64 indents#17774
nicolo-ribaudo merged 1 commit intobabel:mainfrom
YoussefHenna:main

Conversation

@YoussefHenna
Copy link
Copy Markdown
Contributor

Q                       A
Fixed Issues?
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass?
Documentation PR Link
Any Dependency Changes?
License MIT

This check fails when there is exactly 64 indents required. In that case it would access spaceIndents[32] which does not exist since it is initialized above from 0..31. This results in an undefined in place of the expected indentation. An >= avoids this running into this issue

@babel-bot
Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/60854

@YoussefHenna
Copy link
Copy Markdown
Contributor Author

YoussefHenna commented Feb 3, 2026

const x = { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: { a: 1 } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } } };

This is a sample input that will run into the issue in the current versions. And not in the updated version here

Current Version

PR Version

@nicolo-ribaudo nicolo-ribaudo added 7.x: needs backport PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Feb 3, 2026
Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

Thank you!

@liuxingbaoyu
Copy link
Copy Markdown
Member

Thanks!
@nicolo-ribaudo Perhaps this should be marked as next major?

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 3, 2026

Open in StackBlitz

commit: 96d6e18

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix (next major) 🐛 A type of pull request used for our changelog categories for next major release and removed PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Feb 3, 2026
@nicolo-ribaudo nicolo-ribaudo merged commit 3d2f9cb into babel:main Feb 3, 2026
55 of 56 checks passed
@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

i: regression pkg: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories PR: Bug Fix (next major) 🐛 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants