Skip to content

Preserve JavaScript division context across comments - #1511

Open
Divuzki wants to merge 1 commit into
python-babel:masterfrom
Divuzki:fix-js-division-after-comments
Open

Divuzki wants to merge 1 commit into
python-babel:masterfrom
Divuzki:fix-js-division-after-comments

Conversation

@Divuzki

@Divuzki Divuzki commented Nov 28, 2026

Copy link
Copy Markdown

Adding a comment to a JavaScript expression can make Babel drop an unrelated message later in the file. For example, extraction returns no messages for this input:

const average = total // total for the day
    / count;
const label = gettext("Average");
const pattern = /avg/;

The comment resets the lexer's division flag. It then reads everything from the slash before count through the slash before avg as a regular expression, swallowing the call to gettext.

Keep the preceding expression's division flag when yielding a comment token. The regression test checks both comment forms and the extracted message's line number. Both cases failed before the change. All 29 JavaScript extraction and lexer tests pass with it.

This branch has not been deployed

No deployments
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.

1 participant