mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Issue #1547 'use strict' octal escape sequences prohibited
RegExp updated (thanks @michaelficarra) and hex escapes for colors in Cakefile tests updated (thanks @satyr) error message conforms to existing Lexer SyntaxErrors
This commit is contained in:
8
Cakefile
8
Cakefile
@@ -11,10 +11,10 @@ unless process.platform is 'win32'
|
||||
|
||||
bold = red = green = reset = ''
|
||||
if enableColors
|
||||
bold = '\033[0;1m'
|
||||
red = '\033[0;31m'
|
||||
green = '\033[0;32m'
|
||||
reset = '\033[0m'
|
||||
bold = '\x1B[0;1m'
|
||||
red = '\x1B[0;31m'
|
||||
green = '\x1B[0;32m'
|
||||
reset = '\x1B[0m'
|
||||
|
||||
# Built file header.
|
||||
header = """
|
||||
|
||||
@@ -156,6 +156,8 @@ exports.Lexer = class Lexer
|
||||
@token 'STRING', @escapeLines string
|
||||
else
|
||||
return 0
|
||||
if octalEsc = /^(?:\\.|[^\\])*\\[0-7]/.test string
|
||||
@error "octal escape sequences #{string} are not allowed"
|
||||
@line += count string, '\n'
|
||||
string.length
|
||||
|
||||
|
||||
@@ -31,11 +31,20 @@ test "Octal Integer Literals prohibited", ->
|
||||
strictOk '`01`'
|
||||
|
||||
test "Octal Escape Sequences prohibited", ->
|
||||
strict 'e = "\\01"'
|
||||
strict 'e = "\\0777"'
|
||||
strictOk 'e = "\\09"'
|
||||
strictOk 'e = "\\07777"'
|
||||
strictOk "e = `'\033[0;1m'`"
|
||||
strict '"\\0"'
|
||||
strict '"\\7"'
|
||||
strict '"\\000"'
|
||||
strict '"\\777"'
|
||||
strict '"_\\0"'
|
||||
strict '"\\0_"'
|
||||
strict '"_\\0_"'
|
||||
strict '"\\08"'
|
||||
strict '"\\\\\\0"'
|
||||
strictOk '"\\8"'
|
||||
strictOk '"\\\\0"'
|
||||
strictOk '"\\\\\\\\0"'
|
||||
strictOk "`'\\0'`"
|
||||
|
||||
|
||||
test "duplicate property definitions in `Object Literal`s are prohibited", ->
|
||||
strict 'o = {x:1,x:1}'
|
||||
|
||||
Reference in New Issue
Block a user