mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Merge pull request #3849 from lydell/regex-end-invalid-escape
Fix error message for invalid escape at end of regex
This commit is contained in:
@@ -309,8 +309,9 @@
|
||||
break;
|
||||
case !(match = REGEX.exec(this.chunk)):
|
||||
regex = match[0], body = match[1], closed = match[2];
|
||||
this.validateEscapes(regex, {
|
||||
isRegex: true
|
||||
this.validateEscapes(body, {
|
||||
isRegex: true,
|
||||
offsetInChunk: 1
|
||||
});
|
||||
index = regex.length;
|
||||
ref2 = this.tokens, prev = ref2[ref2.length - 1];
|
||||
|
||||
@@ -263,7 +263,7 @@ exports.Lexer = class Lexer
|
||||
{tokens, index} = match
|
||||
when match = REGEX.exec @chunk
|
||||
[regex, body, closed] = match
|
||||
@validateEscapes regex, isRegex: yes
|
||||
@validateEscapes body, isRegex: yes, offsetInChunk: 1
|
||||
index = regex.length
|
||||
[..., prev] = @tokens
|
||||
if prev
|
||||
|
||||
@@ -486,6 +486,13 @@ test "#3795: invalid escapes", ->
|
||||
#{b} \\x0
|
||||
^\^^
|
||||
'''
|
||||
assertErrorFormat '''
|
||||
/ab\\u/
|
||||
''', '''
|
||||
[stdin]:1:4: error: invalid escape sequence \\u
|
||||
/ab\\u/
|
||||
^\^
|
||||
'''
|
||||
|
||||
test "illegal herecomment", ->
|
||||
assertErrorFormat '''
|
||||
|
||||
Reference in New Issue
Block a user