jashkenas/coffee-script — Issue #2141: Parser trips on hard tabs with misleading error message: Unexpected '{'
Author: dkamins
Created: 2012-02-26 04:39:10+00:00
State: open

Presence of hard tabs in certain places in .coffee source causes confusing and irrelevant parser error: **Unexpected '{'**

Tested with v1.2.0.

Specifically see example when object property line with tab is followed by regularly space-indented property line ("Test 2" below).

Test case with proper tabs preserved: http://pastebin.ca/2121616

Or test case inline below, but github converted the tab character to spaces, so you must convert it back yourself:

```coffeescript
# Tabs vs. Spaces in CoffeeScript v1.2.0
#
# This file contains both TABS and SPACES - that's the whole point!
# Copy/Paste carefully.

# Test 1:
ok_in_this_order:
spaces_on_this_line: 2
tabs_on_this_line: 1

# Test 2:
confuses_parser_in_this_order:
tabs_on_this_line: 1
spaces_on_this_line: 2

# Test 2 yields the confusing message on compilation:
# Parse error on line 7: Unexpected '{'

# Error: In test.coffee, Parse error on line 7: Unexpected '{'
# at Object.parseError (/opt/local/lib/node_modules/coffee-script/lib/coffee-script/parser.js:470:11)
# at Object.parse (/opt/local/lib/node_modules/coffee-script/lib/coffee-script/parser.js:546:22)
# at Object.compile (/opt/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:40:22)
# at /opt/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:140:33
# at /opt/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:110:18
# at [object Object]. (fs.js:115:5)
# at [object Object].emit (events.js:64:17)
# at afterRead (fs.js:1112:12)
# at Object.wrapper [as oncomplete] (fs.js:254:17)

```