Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/coffee-script/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/lexer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ exports.Lexer = class Lexer
return 0 unless match = IDENTIFIER.exec @chunk
[input, id, colon] = match

# Uppercase first letter after dash.
id = id.replace /-+([a-zA-Z0-9$_])/g, (string) -> string[1].toUpperCase()

if id is 'own' and @tag() is 'FOR'
@token 'OWN', id
return id.length
Expand Down Expand Up @@ -595,7 +598,7 @@ exports.STRICT_PROSCRIBED = STRICT_PROSCRIBED

# Token matching regexes.
IDENTIFIER = /// ^
( [$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]* )
( [$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*(?:(?:\-[a-zA-Z]+)?)* )
( [^\n\S]* : (?!:) )? # Is this a property name?
///

Expand Down
14 changes: 14 additions & 0 deletions test/assignment.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,17 @@ test '#2213: invocations within destructured parameters', ->
throws -> CoffeeScript.compile '({a()})->'
throws -> CoffeeScript.compile '({a:b()})->'
throws -> CoffeeScript.compile '({a:b.c()})->'

test 'Identifiers with dashes', ->
make-greeting = (who-is-it) -> "Hello, #{who-is-it}"
eq (make-greeting "Ice"), "Hello, Ice"
eq (makeGreeting "Ice"), "Hello, Ice"
obj = {
make-greeting-second: makeGreeting
}
obj.make-greeting = make-greeting
eq (obj.make-greeting "Ice"), "Hello, Ice"
eq (obj.makeGreetingSecond "Ice"), "Hello, Ice"
number = 10
eq number--, 10
eq number-- * 2, 18