{"action":"created","issue":{"url":"https://api.github.com/repos/pkulchenko/ZeroBraneStudio/issues/414","labels_url":"https://api.github.com/repos/pkulchenko/ZeroBraneStudio/issues/414/labels{/name}","comments_url":"https://api.github.com/repos/pkulchenko/ZeroBraneStudio/issues/414/comments","events_url":"https://api.github.com/repos/pkulchenko/ZeroBraneStudio/issues/414/events","html_url":"https://github.com/pkulchenko/ZeroBraneStudio/issues/414","id":58894029,"number":414,"title":"Static analyzer mistakenly reports `first use of unknown field`","user":{"login":"Dmitry-Frantsev","id":4817258,"avatar_url":"https://avatars.githubusercontent.com/u/4817258?v=3","gravatar_id":"","url":"https://api.github.com/users/Dmitry-Frantsev","html_url":"https://github.com/Dmitry-Frantsev","followers_url":"https://api.github.com/users/Dmitry-Frantsev/followers","following_url":"https://api.github.com/users/Dmitry-Frantsev/following{/other_user}","gists_url":"https://api.github.com/users/Dmitry-Frantsev/gists{/gist_id}","starred_url":"https://api.github.com/users/Dmitry-Frantsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dmitry-Frantsev/subscriptions","organizations_url":"https://api.github.com/users/Dmitry-Frantsev/orgs","repos_url":"https://api.github.com/users/Dmitry-Frantsev/repos","events_url":"https://api.github.com/users/Dmitry-Frantsev/events{/privacy}","received_events_url":"https://api.github.com/users/Dmitry-Frantsev/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pkulchenko/ZeroBraneStudio/labels/Bug","name":"Bug","color":"e10c02"}],"state":"closed","locked":false,"assignee":{"login":"pkulchenko","id":77071,"avatar_url":"https://avatars.githubusercontent.com/u/77071?v=3","gravatar_id":"","url":"https://api.github.com/users/pkulchenko","html_url":"https://github.com/pkulchenko","followers_url":"https://api.github.com/users/pkulchenko/followers","following_url":"https://api.github.com/users/pkulchenko/following{/other_user}","gists_url":"https://api.github.com/users/pkulchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/pkulchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkulchenko/subscriptions","organizations_url":"https://api.github.com/users/pkulchenko/orgs","repos_url":"https://api.github.com/users/pkulchenko/repos","events_url":"https://api.github.com/users/pkulchenko/events{/privacy}","received_events_url":"https://api.github.com/users/pkulchenko/received_events","type":"User","site_admin":false},"milestone":null,"comments":12,"created_at":"2015-02-25T12:31:06Z","updated_at":"2015-03-06T17:33:19Z","closed_at":"2015-03-06T06:26:10Z","body":"If closure is a cycle variable, the static analyzer would falsely pop up an error message  when invoking the closure function.\r\n```Lua\r\nlocal function createObject(name)\r\n  local members = {}\r\n  members.test = function()\r\n    print(name..\":test()\")\r\n  end\r\n  return members\r\nend\r\n\r\nlocal obj = createObject(\"obj\")\r\nobj.test()                      -- ok\r\n\r\nlocal objs =\r\n{\r\n  createObject(\"obj1\"),\r\n  createObject(\"obj2\")\r\n}\r\n\r\nfor _,o in ipairs (objs) do\r\n  o.test()                    --!! first use of unknown field 'test' in 'obj'\r\nend\r\n```"},"comment":{"url":"https://api.github.com/repos/pkulchenko/ZeroBraneStudio/issues/comments/77599932","html_url":"https://github.com/pkulchenko/ZeroBraneStudio/issues/414#issuecomment-77599932","issue_url":"https://api.github.com/repos/pkulchenko/ZeroBraneStudio/issues/414","id":77599932,"user":{"login":"pkulchenko","id":77071,"avatar_url":"https://avatars.githubusercontent.com/u/77071?v=3","gravatar_id":"","url":"https://api.github.com/users/pkulchenko","html_url":"https://github.com/pkulchenko","followers_url":"https://api.github.com/users/pkulchenko/followers","following_url":"https://api.github.com/users/pkulchenko/following{/other_user}","gists_url":"https://api.github.com/users/pkulchenko/gists{/gist_id}","starred_url":"https://api.github.com/users/pkulchenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkulchenko/subscriptions","organizations_url":"https://api.github.com/users/pkulchenko/orgs","repos_url":"https://api.github.com/users/pkulchenko/repos","events_url":"https://api.github.com/users/pkulchenko/events{/privacy}","received_events_url":"https://api.github.com/users/pkulchenko/received_events","type":"User","site_admin":false},"created_at":"2015-03-06T17:33:19Z","updated_at":"2015-03-06T17:33:19Z","body":"> You have patched only ipairs() function but missed pairs() function.\r\n\r\nI saw `pairs` as well, but didn't want to change its handling, simply because there is probably no expectation that its element have the same type and there is no way to get the \"first\" element (I can use `next`, but this would need to be done based on AST analysis and I'm not sure yet how to do this).\r\n\r\nAlso, the same problem applies to keys for `pairs`; for `ipairs` it can be set to a number, but for `pairs` this information is not available. The current version simply sets both types to `number` and I haven't changed that. It's easy to apply the same logic to both `pairs` and `ipairs`, but I'm not sure what the implications of that change are.\r\n\r\n> The static analyzer can't determine the type of the argument of ipairs() / pairs() functions when their argument is an argument of a function.\r\n\r\nI'll take a quick look, but the change applied should work in that context as well, so there may be something else at play. We are getting to the point of diminishing returns, so further changes to this logic may not be warranted."}}