Skip to content

Commit 52dd348

Browse files
fixes #1724 for heregexen
TODO: DRY up that regex handling code so we don't have a duplicate test/error
1 parent f4c1b20 commit 52dd348

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

lib/coffee-script/lexer.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ exports.Lexer = class Lexer
209209
[heregex, body, flags] = match
210210
if 0 > body.indexOf '#{'
211211
re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/')
212+
if re.match /^\*/ then @error 'regular expressions cannot begin with `*`'
212213
@token 'REGEX', "/#{ re or '(?:)' }/#{flags}"
213214
return heregex.length
214215
@token 'IDENTIFIER', 'RegExp'

test/regexps.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ test "a heregex will ignore whitespace and comments", ->
5252

5353
test "an empty heregex will compile to an empty, non-capturing group", ->
5454
eq /(?:)/ + '', /// /// + ''
55+
56+
test "#1724: regular expressions beginning with `*`", ->
57+
throws -> CoffeeScript.compile '/// * ///'

0 commit comments

Comments
 (0)