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

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

3 participants

@anttih

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

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 added a commit that closed this issue Dec 27, 2012
@gkz fix #151 4fab36b
@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