diff --git a/lib/lexer.js b/lib/lexer.js index 739e2ca1..6570b161 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -37,7 +37,7 @@ return (new Rewriter).rewrite(this.tokens); }; Lexer.prototype.identifierToken = function() { - var colon, forcedIdentifier, id, input, match, prev, tag, _ref, _ref2, _ref3; + var colon, forcedIdentifier, id, input, match, prev, tag, _ref, _ref2; if (!(match = IDENTIFIER.exec(this.chunk))) { return 0; } @@ -46,11 +46,11 @@ this.token('OWN', id); return id.length; } - forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref = prev[0]) === '.' || _ref === '?.') || !prev.spaced && ((_ref2 = prev[0]) === '@' || _ref2 === '::')); + forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref = prev[0]) === '.' || _ref === '?.' || _ref === '::') || !prev.spaced && prev[0] === '@'); tag = 'IDENTIFIER'; if (__indexOf.call(JS_KEYWORDS, id) >= 0 || !forcedIdentifier && __indexOf.call(COFFEE_KEYWORDS, id) >= 0) { tag = id.toUpperCase(); - if (tag === 'WHEN' && (_ref3 = this.tag(), __indexOf.call(LINE_BREAK, _ref3) >= 0)) { + if (tag === 'WHEN' && (_ref2 = this.tag(), __indexOf.call(LINE_BREAK, _ref2) >= 0)) { tag = 'LEADING_WHEN'; } else if (tag === 'FOR') { this.seenFor = true; diff --git a/src/lexer.coffee b/src/lexer.coffee index cfb4aaf2..8ea075ec 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -80,8 +80,8 @@ exports.Lexer = class Lexer @token 'OWN', id return id.length forcedIdentifier = colon or - (prev = last @tokens) and (prev[0] in ['.', '?.'] or - not prev.spaced and prev[0] in ['@', '::']) + (prev = last @tokens) and (prev[0] in ['.', '?.', '::'] or + not prev.spaced and prev[0] is '@') tag = 'IDENTIFIER' if id in JS_KEYWORDS or diff --git a/test/formatting.coffee b/test/formatting.coffee index e8f98f8f..2f43d239 100644 --- a/test/formatting.coffee +++ b/test/formatting.coffee @@ -75,8 +75,8 @@ test "`?.` and `::` should continue lines", -> doesNotThrow -> CoffeeScript.compile """ oh. yes - oh. true - oh . return + oh?. true + oh:: return """ # Array Literals