Keep TypeScript division expressions out of regex highlighting - #4219
Open
justadityaraj wants to merge 1 commit into
Open
Keep TypeScript division expressions out of regex highlighting#4219justadityaraj wants to merge 1 commit into
justadityaraj wants to merge 1 commit into
Conversation
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.
Context
TypeScript's regular-expression rule cannot distinguish regex literals from division expressions with the syntax highlighter's regular-expression engine. It therefore treats text between division operators, such as
/ 2.0, height /, as a regex constant. JavaScript already disables the same ambiguous rule, and the maintainer accepted that fallback for TypeScript in #3874.Changes
constanthighlighting in a chained division expression.User impact
Ordinary TypeScript division expressions keep their correct token colors instead of having the operands between slash characters displayed as a regex literal. Regex literals remain unclassified rather than risking false highlighting across unrelated code.
Verification
master— failed with division highlighted asconstant.go test ./runtime -run TestTypeScriptDivisionIsNotRegexp -count=10— passed.go test ./... -count=1— passed.go generate ./runtime— passed with no additional tracked changes.go build ./cmd/micro— passed.git diff --check— passed.go vet ./...— retains the existing unkeyed-literal and copied-lock warnings reproduced on cleanmaster.masterand the corrected division coloring after the change.Fixes #3874