Skip to content

Lexer: Input of asterisk (*) throws exception #4575

@richdougherty

Description

@richdougherty

I'm upgrading the sbt-coffeescript plugin and encountered an error on one of our unit tests. When upgrading from CoffeeScript 1.7.1 to 1.11.0 (I know this isn't the latest version) I noticed that our unit test that extracts line numbers from compile errors was failing. This error also occurs on the online console (version 1.12.6).

When the input to the compile function is * or *whateveryouwanthere then the lexer throws an exception.

TypeError: Cannot read property '0' of undefined
  at Lexer.exports.Lexer.Lexer.literalToken (...lib/coffee-script/lexer.js:550:39)
  at Lexer.exports.Lexer.Lexer.tokenize (...lib/coffee-script/lexer.js:35:203)
  at Object.<anonymous> (...lib/coffee-script/coffee-script.js:63:20)
  at Object.compile (...lib/coffee-script/coffee-script.js:44:19)
  at ../coffee.js:58:46
  at tryToString (fs.js:414:3)
  at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12)

The expected result was an error like Error on line 1: unexpected *.

The lexer handles this properly if the * character is on the start of line 2 instead of line 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions