-
Notifications
You must be signed in to change notification settings - Fork 2k
[CS2] Unicode code point escapes on 2, fixes #4248 #4520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CS2] Unicode code point escapes on 2, fixes #4248 #4520
Conversation
@helixbass Could you ping me when the diff is readable? :) |
@lydell sorry I wrongly assumed that once |
src/lexer.coffee
Outdated
replaceUnicodeCodePointEscapes: (str, options) -> | ||
shouldReplace = options.flags? and options.flags.indexOf('u') is -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'u' not in options.flags
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lydell as currently written, options
won't always contain a flags
key (only does if this is for a regex, in which case flags
will be set to the regex flags string) and not in
seems to break with an undefined
arg. Does seem like there should be a simpler way to write this though - I guess you could do something like options.flags ?= 'u'
before 'u' not in options.flags
to handle the string case but that seems confusing semantically. Or could refactor to pass in eg dontReplace
option instead of flags
but it seemed very clean to just pass around existing flags
and then have the logic for interpreting it with regards to code point escape replacement be contained in this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant only replacing the right side of the and
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lydell ok yup that reads well, updated
@GeoffreyBooth requested that I refactor toJS()
into a shared test helper so I opened a pull request #4522 for that (against master
). Perhaps wait to merge this one until we've gone through the cycle of merging that into master
, merging master
into 2
, and re-merging 2
here (or it may not matter if that refactor doesn't cause any merge conflicts here)?
Unfortunately, there are merge conflicts now :( |
Fixes #4248: contains the Unicode code point escape handling specific to
2
branch (as suggested by @lydell)This currently also includes some commits from
master
(including my code point escape stuff targeted againstmaster
ie #4498) that haven't been merged into2
yet. If it's preferable to separate that out, I can open a pull request for my2_merged_master
branch (against2
branch), which just containsmaster
merged into2
But otherwise here is the diff of just my
2
-specific changes. Basically we just have to pass around the (he)regexflags
in order to be able to distinguish non-u
-regexes (whose code point escapes should be rewritten to normal Unicode escapes) from strings/u
-regexes (whose code point escapes should not be rewritten)