diff --git a/lib/lexer.js b/lib/lexer.js index 396d2704..958f4043 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -607,7 +607,7 @@ STRING_NEWLINES = /\n[ \t]*/g; NO_NEWLINE = /^([+\*&|\/\-%=<>:!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/; HEREDOC_INDENT = /(\n+([ \t]*)|^([ \t]+))/g; - ASSIGNED = /^([a-zA-Z\$_]\w*[ \t]*?[:=])/; + ASSIGNED = /^([a-zA-Z\$_]\w*[ \t]*?[:=][^=])/; NEXT_CHARACTER = /^\s*(\S)/; NOT_REGEX = ['NUMBER', 'REGEX', '++', '--', 'FALSE', 'NULL', 'TRUE', ']']; CALLABLE = ['IDENTIFIER', 'SUPER', ')', ']', '}', 'STRING', '@', 'THIS', '?', '::']; diff --git a/src/lexer.coffee b/src/lexer.coffee index 3cca3924..2244b762 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -530,7 +530,7 @@ MULTILINER : /\n/g STRING_NEWLINES : /\n[ \t]*/g NO_NEWLINE : /^([+\*&|\/\-%=<>:!.\\][<>=&|]*|and|or|is|isnt|not|delete|typeof|instanceof)$/ HEREDOC_INDENT : /(\n+([ \t]*)|^([ \t]+))/g -ASSIGNED : /^([a-zA-Z\$_]\w*[ \t]*?[:=])/ +ASSIGNED : /^([a-zA-Z\$_]\w*[ \t]*?[:=][^=])/ NEXT_CHARACTER : /^\s*(\S)/ # Tokens which a regular expression will never immediately follow, but which diff --git a/test/test_literals.coffee b/test/test_literals.coffee index a062f32e..13e629e3 100644 --- a/test/test_literals.coffee +++ b/test/test_literals.coffee @@ -114,3 +114,10 @@ obj: {class: 'höt'} obj.function: 'dog' ok obj.class + obj.function is 'hötdog' + + +# But keyword assignment should be smart enough not to stringify variables. +func: -> + this == 'this' + +ok func() is false