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:
commit
dc8a2b17d0
|
@ -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 '''
|
||||
|
|
Loading…
Reference in New Issue