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

Named functions with -d switch don't compile #151

Closed
anttih opened this Issue Aug 19, 2012 · 1 comment

Comments

Projects
None yet
3 participants
@anttih

anttih commented Aug 19, 2012

Named functions don't compile when auto-importing prelude with the -d switch.

$ echo "function hello\n  1" | livescript -c -d -s
SyntaxError: misplaced function declaration on line 3

$ echo "function hello\n  1" | livescript -c -s
(function(){
  function hello(){
    return 1;
  }
}).call(this);
@vendethiel

This comment has been minimized.

Contributor

vendethiel commented Dec 8, 2012

Seems to be a problem with scoping, pscope is o.block.scope or @carp 'misplaced function declaration' has o.block.scope null. d54a8dd was meant to fix the issue with base indentation, but created this.
Not sure what's the best way to fix this. A simple fix could be this : but will probably fail in one case or another

    if o.prelude
      base-indent = (input == /^([\s\t]+)/).0
      t.input = """
      #{base-indent}if   window?
      #{base-indent}then prelude.installPrelude window
      #{base-indent}else (require 'prelude-ls').installPrelude global
      \n""" + t.input

@gkz gkz closed this in 4fab36b Dec 27, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment