{"action":"created","comment":{"url":"https://api.github.com/repos/opal/opal/pulls/comments/66088717","id":66088717,"diff_hunk":"@@ -8,34 +8,39 @@ class CaseNode < Base\n       children :condition\n \n       def compile\n-        handled_else = false\n-\n         compiler.in_case do\n-          if condition\n-            case_stmt[:cond] = true\n-            add_local '$case'\n+          compile_code\n \n-            push \"$case = \", expr(condition), \";\"\n-          end\n+          wrap '(function() {', '})()' if needs_closure?\n+        end\n+      end\n \n-          case_parts.each_with_index do |wen, idx|\n-            if wen and wen.type == :when\n-              compiler.returns(wen) if needs_closure?\n-              push \"else \" unless idx == 0\n-              push stmt(wen)\n-            elsif wen # s(:else)\n-              handled_else = true\n-              wen = compiler.returns(wen) if needs_closure?\n-              push \"else {\", stmt(wen), \"}\"\n-            end\n-          end\n+      def compile_code\n+        handled_else = false\n \n-          # if we are having a closure, we must return a usable value\n-          if needs_closure? and !handled_else\n-            push \"else { return nil }\"\n+        if condition\n+          case_stmt[:cond] = true\n+          add_local '$case'\n+\n+          push \"$case = \", expr(condition), \";\"\n+          empty_line\n+        end\n+\n+        case_parts.each_with_index do |wen, idx|\n+          if wen and wen.type == :when\n+            wen = compiler.returns(wen) if needs_closure?\n+            push \"else \" unless idx == 0\n+            push stmt(wen)\n+          elsif wen # s(:else)","path":"lib/opal/nodes/case.rb","position":48,"original_position":48,"commit_id":"16bee30f039d45b1480b1c8b33a2628d09366d13","original_commit_id":"16bee30f039d45b1480b1c8b33a2628d09366d13","user":{"login":"meh","id":40204,"avatar_url":"https://avatars.githubusercontent.com/u/40204?v=3","gravatar_id":"","url":"https://api.github.com/users/meh","html_url":"https://github.com/meh","followers_url":"https://api.github.com/users/meh/followers","following_url":"https://api.github.com/users/meh/following{/other_user}","gists_url":"https://api.github.com/users/meh/gists{/gist_id}","starred_url":"https://api.github.com/users/meh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meh/subscriptions","organizations_url":"https://api.github.com/users/meh/orgs","repos_url":"https://api.github.com/users/meh/repos","events_url":"https://api.github.com/users/meh/events{/privacy}","received_events_url":"https://api.github.com/users/meh/received_events","type":"User","site_admin":false},"body":"I'm not sure I like this.\r\n\r\nI think it would be better to check `if wen` and then do a `case`.","created_at":"2016-06-07T15:05:06Z","updated_at":"2016-06-07T15:05:06Z","html_url":"https://github.com/opal/opal/pull/1465#discussion_r66088717","pull_request_url":"https://api.github.com/repos/opal/opal/pulls/1465","_links":{"self":{"href":"https://api.github.com/repos/opal/opal/pulls/comments/66088717"},"html":{"href":"https://github.com/opal/opal/pull/1465#discussion_r66088717"},"pull_request":{"href":"https://api.github.com/repos/opal/opal/pulls/1465"}}},"pull_request":{"url":"https://api.github.com/repos/opal/opal/pulls/1465","id":68759274,"html_url":"https://github.com/opal/opal/pull/1465","diff_url":"https://github.com/opal/opal/pull/1465.diff","patch_url":"https://github.com/opal/opal/pull/1465.patch","issue_url":"https://api.github.com/repos/opal/opal/issues/1465","number":1465,"state":"open","locked":false,"title":"Replace Opal::Parser/Opal::Lexer/Opal::Sexp with parser/ast gems.","user":{"login":"iliabylich","id":1265492,"avatar_url":"https://avatars.githubusercontent.com/u/1265492?v=3","gravatar_id":"","url":"https://api.github.com/users/iliabylich","html_url":"https://github.com/iliabylich","followers_url":"https://api.github.com/users/iliabylich/followers","following_url":"https://api.github.com/users/iliabylich/following{/other_user}","gists_url":"https://api.github.com/users/iliabylich/gists{/gist_id}","starred_url":"https://api.github.com/users/iliabylich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iliabylich/subscriptions","organizations_url":"https://api.github.com/users/iliabylich/orgs","repos_url":"https://api.github.com/users/iliabylich/repos","events_url":"https://api.github.com/users/iliabylich/events{/privacy}","received_events_url":"https://api.github.com/users/iliabylich/received_events","type":"User","site_admin":false},"body":"AST, Parser and MSpec are compilable and runnable.\r\n\r\n``` sh\r\n$ opal -gast -gparser -e \"require 'opal-parser'; p eval('123')\"\r\nObject freezing is not supported by Opal\r\n123\r\n```\r\n\r\nRemoved unused nodes.\r\nAdded missing nodes :smile: ","created_at":"2016-05-03T19:15:28Z","updated_at":"2016-06-07T15:05:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"692371c73048249be8304fa67eeb01cfbd81eb20","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opal/opal/pulls/1465/commits","review_comments_url":"https://api.github.com/repos/opal/opal/pulls/1465/comments","review_comment_url":"https://api.github.com/repos/opal/opal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opal/opal/issues/1465/comments","statuses_url":"https://api.github.com/repos/opal/opal/statuses/16bee30f039d45b1480b1c8b33a2628d09366d13","head":{"label":"opal:iliabylich/replace-opal-parser-with-parser-gem","ref":"iliabylich/replace-opal-parser-with-parser-gem","sha":"16bee30f039d45b1480b1c8b33a2628d09366d13","user":{"login":"opal","id":842643,"avatar_url":"https://avatars.githubusercontent.com/u/842643?v=3","gravatar_id":"","url":"https://api.github.com/users/opal","html_url":"https://github.com/opal","followers_url":"https://api.github.com/users/opal/followers","following_url":"https://api.github.com/users/opal/following{/other_user}","gists_url":"https://api.github.com/users/opal/gists{/gist_id}","starred_url":"https://api.github.com/users/opal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opal/subscriptions","organizations_url":"https://api.github.com/users/opal/orgs","repos_url":"https://api.github.com/users/opal/repos","events_url":"https://api.github.com/users/opal/events{/privacy}","received_events_url":"https://api.github.com/users/opal/received_events","type":"Organization","site_admin":false},"repo":{"id":184366,"name":"opal","full_name":"opal/opal","owner":{"login":"opal","id":842643,"avatar_url":"https://avatars.githubusercontent.com/u/842643?v=3","gravatar_id":"","url":"https://api.github.com/users/opal","html_url":"https://github.com/opal","followers_url":"https://api.github.com/users/opal/followers","following_url":"https://api.github.com/users/opal/following{/other_user}","gists_url":"https://api.github.com/users/opal/gists{/gist_id}","starred_url":"https://api.github.com/users/opal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opal/subscriptions","organizations_url":"https://api.github.com/users/opal/orgs","repos_url":"https://api.github.com/users/opal/repos","events_url":"https://api.github.com/users/opal/events{/privacy}","received_events_url":"https://api.github.com/users/opal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opal/opal","description":"Ruby to JavaScript compiler","fork":false,"url":"https://api.github.com/repos/opal/opal","forks_url":"https://api.github.com/repos/opal/opal/forks","keys_url":"https://api.github.com/repos/opal/opal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opal/opal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opal/opal/teams","hooks_url":"https://api.github.com/repos/opal/opal/hooks","issue_events_url":"https://api.github.com/repos/opal/opal/issues/events{/number}","events_url":"https://api.github.com/repos/opal/opal/events","assignees_url":"https://api.github.com/repos/opal/opal/assignees{/user}","branches_url":"https://api.github.com/repos/opal/opal/branches{/branch}","tags_url":"https://api.github.com/repos/opal/opal/tags","blobs_url":"https://api.github.com/repos/opal/opal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opal/opal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opal/opal/git/refs{/sha}","trees_url":"https://api.github.com/repos/opal/opal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opal/opal/statuses/{sha}","languages_url":"https://api.github.com/repos/opal/opal/languages","stargazers_url":"https://api.github.com/repos/opal/opal/stargazers","contributors_url":"https://api.github.com/repos/opal/opal/contributors","subscribers_url":"https://api.github.com/repos/opal/opal/subscribers","subscription_url":"https://api.github.com/repos/opal/opal/subscription","commits_url":"https://api.github.com/repos/opal/opal/commits{/sha}","git_commits_url":"https://api.github.com/repos/opal/opal/git/commits{/sha}","comments_url":"https://api.github.com/repos/opal/opal/comments{/number}","issue_comment_url":"https://api.github.com/repos/opal/opal/issues/comments{/number}","contents_url":"https://api.github.com/repos/opal/opal/contents/{+path}","compare_url":"https://api.github.com/repos/opal/opal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opal/opal/merges","archive_url":"https://api.github.com/repos/opal/opal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opal/opal/downloads","issues_url":"https://api.github.com/repos/opal/opal/issues{/number}","pulls_url":"https://api.github.com/repos/opal/opal/pulls{/number}","milestones_url":"https://api.github.com/repos/opal/opal/milestones{/number}","notifications_url":"https://api.github.com/repos/opal/opal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opal/opal/labels{/name}","releases_url":"https://api.github.com/repos/opal/opal/releases{/id}","deployments_url":"https://api.github.com/repos/opal/opal/deployments","created_at":"2009-04-24T08:53:34Z","updated_at":"2016-06-07T11:03:13Z","pushed_at":"2016-06-07T14:57:08Z","git_url":"git://github.com/opal/opal.git","ssh_url":"git@github.com:opal/opal.git","clone_url":"https://github.com/opal/opal.git","svn_url":"https://github.com/opal/opal","homepage":"https://opal.github.io","size":16392,"stargazers_count":3251,"watchers_count":3251,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":227,"mirror_url":null,"open_issues_count":108,"forks":227,"open_issues":108,"watchers":3251,"default_branch":"master"}},"base":{"label":"opal:master","ref":"master","sha":"1079233fe319e9436de2f238bbd6a5c2d84298d1","user":{"login":"opal","id":842643,"avatar_url":"https://avatars.githubusercontent.com/u/842643?v=3","gravatar_id":"","url":"https://api.github.com/users/opal","html_url":"https://github.com/opal","followers_url":"https://api.github.com/users/opal/followers","following_url":"https://api.github.com/users/opal/following{/other_user}","gists_url":"https://api.github.com/users/opal/gists{/gist_id}","starred_url":"https://api.github.com/users/opal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opal/subscriptions","organizations_url":"https://api.github.com/users/opal/orgs","repos_url":"https://api.github.com/users/opal/repos","events_url":"https://api.github.com/users/opal/events{/privacy}","received_events_url":"https://api.github.com/users/opal/received_events","type":"Organization","site_admin":false},"repo":{"id":184366,"name":"opal","full_name":"opal/opal","owner":{"login":"opal","id":842643,"avatar_url":"https://avatars.githubusercontent.com/u/842643?v=3","gravatar_id":"","url":"https://api.github.com/users/opal","html_url":"https://github.com/opal","followers_url":"https://api.github.com/users/opal/followers","following_url":"https://api.github.com/users/opal/following{/other_user}","gists_url":"https://api.github.com/users/opal/gists{/gist_id}","starred_url":"https://api.github.com/users/opal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opal/subscriptions","organizations_url":"https://api.github.com/users/opal/orgs","repos_url":"https://api.github.com/users/opal/repos","events_url":"https://api.github.com/users/opal/events{/privacy}","received_events_url":"https://api.github.com/users/opal/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opal/opal","description":"Ruby to JavaScript compiler","fork":false,"url":"https://api.github.com/repos/opal/opal","forks_url":"https://api.github.com/repos/opal/opal/forks","keys_url":"https://api.github.com/repos/opal/opal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opal/opal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opal/opal/teams","hooks_url":"https://api.github.com/repos/opal/opal/hooks","issue_events_url":"https://api.github.com/repos/opal/opal/issues/events{/number}","events_url":"https://api.github.com/repos/opal/opal/events","assignees_url":"https://api.github.com/repos/opal/opal/assignees{/user}","branches_url":"https://api.github.com/repos/opal/opal/branches{/branch}","tags_url":"https://api.github.com/repos/opal/opal/tags","blobs_url":"https://api.github.com/repos/opal/opal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opal/opal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opal/opal/git/refs{/sha}","trees_url":"https://api.github.com/repos/opal/opal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opal/opal/statuses/{sha}","languages_url":"https://api.github.com/repos/opal/opal/languages","stargazers_url":"https://api.github.com/repos/opal/opal/stargazers","contributors_url":"https://api.github.com/repos/opal/opal/contributors","subscribers_url":"https://api.github.com/repos/opal/opal/subscribers","subscription_url":"https://api.github.com/repos/opal/opal/subscription","commits_url":"https://api.github.com/repos/opal/opal/commits{/sha}","git_commits_url":"https://api.github.com/repos/opal/opal/git/commits{/sha}","comments_url":"https://api.github.com/repos/opal/opal/comments{/number}","issue_comment_url":"https://api.github.com/repos/opal/opal/issues/comments{/number}","contents_url":"https://api.github.com/repos/opal/opal/contents/{+path}","compare_url":"https://api.github.com/repos/opal/opal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opal/opal/merges","archive_url":"https://api.github.com/repos/opal/opal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opal/opal/downloads","issues_url":"https://api.github.com/repos/opal/opal/issues{/number}","pulls_url":"https://api.github.com/repos/opal/opal/pulls{/number}","milestones_url":"https://api.github.com/repos/opal/opal/milestones{/number}","notifications_url":"https://api.github.com/repos/opal/opal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opal/opal/labels{/name}","releases_url":"https://api.github.com/repos/opal/opal/releases{/id}","deployments_url":"https://api.github.com/repos/opal/opal/deployments","created_at":"2009-04-24T08:53:34Z","updated_at":"2016-06-07T11:03:13Z","pushed_at":"2016-06-07T14:57:08Z","git_url":"git://github.com/opal/opal.git","ssh_url":"git@github.com:opal/opal.git","clone_url":"https://github.com/opal/opal.git","svn_url":"https://github.com/opal/opal","homepage":"https://opal.github.io","size":16392,"stargazers_count":3251,"watchers_count":3251,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":227,"mirror_url":null,"open_issues_count":108,"forks":227,"open_issues":108,"watchers":3251,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/opal/opal/pulls/1465"},"html":{"href":"https://github.com/opal/opal/pull/1465"},"issue":{"href":"https://api.github.com/repos/opal/opal/issues/1465"},"comments":{"href":"https://api.github.com/repos/opal/opal/issues/1465/comments"},"review_comments":{"href":"https://api.github.com/repos/opal/opal/pulls/1465/comments"},"review_comment":{"href":"https://api.github.com/repos/opal/opal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opal/opal/pulls/1465/commits"},"statuses":{"href":"https://api.github.com/repos/opal/opal/statuses/16bee30f039d45b1480b1c8b33a2628d09366d13"}}}}
{"actor":{"display_login":"meh"}}