{"action":"created","issue":{"url":"https://api.github.com/repos/ark-lang/ark/issues/419","labels_url":"https://api.github.com/repos/ark-lang/ark/issues/419/labels{/name}","comments_url":"https://api.github.com/repos/ark-lang/ark/issues/419/comments","events_url":"https://api.github.com/repos/ark-lang/ark/issues/419/events","html_url":"https://github.com/ark-lang/ark/issues/419","id":89411408,"number":419,"title":"Support for nested scopes","user":{"login":"naegelejd","id":1110252,"avatar_url":"https://avatars.githubusercontent.com/u/1110252?v=3","gravatar_id":"","url":"https://api.github.com/users/naegelejd","html_url":"https://github.com/naegelejd","followers_url":"https://api.github.com/users/naegelejd/followers","following_url":"https://api.github.com/users/naegelejd/following{/other_user}","gists_url":"https://api.github.com/users/naegelejd/gists{/gist_id}","starred_url":"https://api.github.com/users/naegelejd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naegelejd/subscriptions","organizations_url":"https://api.github.com/users/naegelejd/orgs","repos_url":"https://api.github.com/users/naegelejd/repos","events_url":"https://api.github.com/users/naegelejd/events{/privacy}","received_events_url":"https://api.github.com/users/naegelejd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-18T22:22:13Z","updated_at":"2015-06-18T22:26:16Z","closed_at":null,"body":"There doesn't seem to exist support for nested scopes, e.g.\r\n```\r\n[c] func printf(fmt: str, ...);\r\n\r\nfunc main(): int {\r\n    mut x: int = 5;\r\n\r\n    {\r\n        printf(\"x = %d\\n\", x);\r\n    }\r\n    printf(\"x = %d\\n\", x);\r\n\r\n    return 0;\r\n}\r\n```\r\nfails with parser error: `Parser error: [tests/if_else_test.ark:6:5] Expected statement, found something else`.\r\n\r\nAlso, if you add `mut x: int = 4;` inside the nested scope, the parser fails with: `Parser error: [tests/if_else_test.ark:6:5] Malformed assignment statement`. This second problem is a combination of the the first (no nested scopes) as well as [this for-loop here](https://github.com/ark-lang/ark/blob/9b6428884e35ac35886f72ad741a890fca731c4b/parser/parser.go#L229-L235), which just eats just about everything in its path until it finds an `=`.\r\n\r\nIn my opinion, a `block` *is* actually a statement itself, it just happens to be a collection of statements with its own scope, so `blocks` should also be parsed in `parseStat`."},"comment":{"url":"https://api.github.com/repos/ark-lang/ark/issues/comments/113305110","html_url":"https://github.com/ark-lang/ark/issues/419#issuecomment-113305110","issue_url":"https://api.github.com/repos/ark-lang/ark/issues/419","id":113305110,"user":{"login":"MovingtoMars","id":596124,"avatar_url":"https://avatars.githubusercontent.com/u/596124?v=3","gravatar_id":"","url":"https://api.github.com/users/MovingtoMars","html_url":"https://github.com/MovingtoMars","followers_url":"https://api.github.com/users/MovingtoMars/followers","following_url":"https://api.github.com/users/MovingtoMars/following{/other_user}","gists_url":"https://api.github.com/users/MovingtoMars/gists{/gist_id}","starred_url":"https://api.github.com/users/MovingtoMars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MovingtoMars/subscriptions","organizations_url":"https://api.github.com/users/MovingtoMars/orgs","repos_url":"https://api.github.com/users/MovingtoMars/repos","events_url":"https://api.github.com/users/MovingtoMars/events{/privacy}","received_events_url":"https://api.github.com/users/MovingtoMars/received_events","type":"User","site_admin":false},"created_at":"2015-06-18T22:26:16Z","updated_at":"2015-06-18T22:26:16Z","body":"Yes, I agree with this.\r\n\r\nWhat about, adding BlockStat that just holds a *Block, much in the way CallStat just holds a *CallExpr."}}