Skip to content

Extra space in array definition breaks following indentation scopes. #2341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
enyo opened this issue May 17, 2012 · 6 comments
Closed

Extra space in array definition breaks following indentation scopes. #2341

enyo opened this issue May 17, 2012 · 6 comments

Comments

@enyo
Copy link

enyo commented May 17, 2012

This coffee script:

describe "test", () ->
  x = [
    1, 2
   ] # <-- A space at the beginning of this line
  describe "innerTest", () ->
    "Wrong indentation"

(note the extra space before ])

compiles to:

describe("test", function() {
  var x;
  return x = [1, 2];
});

describe("innerTest", function() {
  return "Wrong indentation";
});

This only happens with exactly one space. Two spaces pass just fine, and more result in a syntax error.

@michaelficarra
Copy link
Collaborator

Not exactly. It happens with any number greater than zero and less than the number of spaces you're using as indentation. See #1275. Closing as duplicate.

@enyo
Copy link
Author

enyo commented May 17, 2012

Sorry, I went through all the bug reports but didn't make the connection to this one.

But actually: no, it doesn't happen with 2 spaces. Two spaces and no (EDIT) space result in exactly the same code. (not that it matters...)

@michaelficarra
Copy link
Collaborator

I believe you are mistaken. My previous statement is correct. Paste shell sessions if you'd like to supplement your argument.

0/3 extra spaces

$ coffee -bsp
do ->
   a = [
      0
   ]
   b = 1
(function() {
  var a, b;
  a = [0];
  return b = 1;
})();

1/3 extra spaces

$ coffee -bsp
do ->
   a = [
      0
    ]
   b = 1
var b;

(function() {
  var a;
  return a = [0];
})();

b = 1;

2/3 extra spaces

$ coffee -bsp
do -> 
   a = [
      0
     ]
   b = 1
var b;

(function() {
  var a;
  return a = [0];
})();

b = 1;

3/3 extra spaces

$ coffee -bsp
do ->
   a = [
      0
      ]
   b = 1
(function() {
  var a, b;
  a = [0];
  return b = 1;
})();
$ 

@enyo
Copy link
Author

enyo commented May 17, 2012

With one space:

enyo@matbook:~$ coffee -bsp
describe "test", () ->
  x = [
    1, 2
   ] # <-- One space
  describe "innerTest", () ->
    "Wrong indentation"

# Results in:

describe("test", function() {
  var x;
  return x = [1, 2];
});

describe("innerTest", function() {
  return "Wrong indentation";
});

With two spaces:

enyo@matbook:~$ coffee -bsp
describe "test", () ->
  x = [
    1, 2
    ] # <-- Two spaces
  describe "innerTest", () ->
    "Correct indentation"

# Results in:

describe("test", function() {
  var x;
  x = [1, 2];
  return describe("innerTest", function() {
    return "Correct indentation";
  });
});

@michaelficarra
Copy link
Collaborator

So, you agree with me then, correct? Your comment

Two spaces and one space result in exactly the same code

has been shown to be false.

@enyo
Copy link
Author

enyo commented May 17, 2012

Sorry.. that was a mistake.. Two spaces and no space are exactly identical (I updated my response).

The current block is only terminated in my case, when there is exactly one space. Zero and 2 spaces are the same (result in the normal expected code). 3 Spaces result in a parse error.

@xixixao xixixao mentioned this issue Jan 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants