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

Open
gfwilliams opened this issue Aug 27, 2019 · 0 comments
Open

Accessing `undefined` argument via arguments causes error #1691

gfwilliams opened this issue Aug 27, 2019 · 0 comments

Comments

@gfwilliams
Copy link
Member

@gfwilliams gfwilliams commented Aug 27, 2019

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.