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

loadstring behaves differently #32

Open
dgjxqz opened this issue Sep 2, 2013 · 0 comments
Open

loadstring behaves differently #32

dgjxqz opened this issue Sep 2, 2013 · 0 comments

Comments

@dgjxqz
Copy link

dgjxqz commented Sep 2, 2013

3 Issues:

  1. Arguments not passed to the top level function of a parsed chunk (via ...).
  2. Parsed chunk has it's own global environment.
  3. Lua understands calling function with func()() but javascript needs () around i.e. (func())()

From command line,

% lua -e 'var=123 loadstring"print(var,...)"(456)'

gives:

123     456

In chrome,

<script src=lua+parser.min.js></script>
<script>lua_load('var=123 loadstring"print(var,...)"(456)')();</script>
<script>lua_load('var=123 (loadstring"print(var,...)")(456)')();</script>
<script>lua_load('var=123 (loadstring"print(var)")(456)')();</script>

gives:

Uncaught Error: Parse error on line 1:
...print(var,...)"(456)
-----------------------^
Expecting '(', ':', '.', 'STRING', '{', '[', got 'EOF' lua+parser.min.js:127
Uncaught ReferenceError: varargs is not defined
undefined lua+parser.min.js:16
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

1 participant