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

Accessing undefined argument via arguments causes error #1691

Closed
gfwilliams opened this issue Aug 27, 2019 · 4 comments
Closed

Accessing undefined argument via arguments causes error #1691

gfwilliams opened this issue Aug 27, 2019 · 4 comments

Comments

@gfwilliams
Copy link
Member

Mentioned here http://forum.espruino.com/conversations/337375

arguments[1] causes an error inside the function (a bug), but accessing outside doesn't

>function foo(x,y) {
:  z=arguments;trace(arguments); 
:  for (var i = 0; i < arguments.length; i++)
:    console.log(arguments[i]);   
:}
=function (x,y) { ... }
>foo(1,2) 
#92[r0,l1] Array(2) [ 
  #134[r1,l2] Name Integer 0= int 1

  #121[r1,l2] Name Integer 1= int 2

]
1
2
=undefined
>foo(42) 
#43[r0,l1] Array(2) [ 
  #90[r1,l2] Name Integer 0= int 42

  #136[r1,l2] Name Integer 1    undefined 
]
42
Uncaught ReferenceError: "1" is not defined
 at line 3 col 28
    console.log(arguments[i]);
                           ^
in function "foo" called from line 1 col 7
foo(42)
      ^
>console.log(z[42])
undefined
@kiranshila
Copy link
Contributor

Any movement on this - it is still an issue.

@kiranshila
Copy link
Contributor

This causes errors all over place for ClojureScript.

(function(){return [x=arguments,x][1][0];})(undefined)
=undefined

A neat hack to get around the problem

@gfwilliams
Copy link
Member Author

Just fixed

@kiranshila
Copy link
Contributor

You're a machine @gfwilliams! Thanks!

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

2 participants