Skip to content
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

Failure to parse dot operator on a new line #153

Closed
sky-dev opened this issue Feb 2, 2013 · 2 comments
Closed

Failure to parse dot operator on a new line #153

sky-dev opened this issue Feb 2, 2013 · 2 comments
Milestone

Comments

@sky-dev
Copy link

sky-dev commented Feb 2, 2013

First, thanks for creating this great project. I'm really looking forward to getting my project set to use source maps!

I had a compilation error on some code that works at coffeescript.org that I thought you might be interested in.

On line 7 of the code below a syntax error is thrown, because the dot operator is on a new line.

Erring:

Page = () ->
  @title = "default"
  title: () -> @title
  setTitle: (value) -> @title = value

angular
  .module("test.factories", [])
  .factory("Page", () -> new Page())
coffee

Workaround:

Page = () ->
  @title = "default"
  title: () -> @title
  setTitle: (value) -> @title = value

angular.module("test.factories", []).factory("Page", () -> new Page())
coffee
@MartinodF
Copy link

+1 This is a really common pattern when using chaining apis.

This is another workaround and works as expected:

angular
.module("test.factories", [])
.factory("Page", () -> new Page())

Be sure to use parentheses around the arguments. This does not work:

angular
.module "test.factories", []
.factory "Page", () -> new Page()

because .factory is called on []:

angular.module('test.factories', [].factory('Page', function () {
  return new Page;
}));

@imcotton
Copy link

I think here is another scenario fails:

$.get('url')
  .done ->
    alert 'success'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants