{"action":"created","comment":{"url":"https://api.github.com/repos/TheDan64/limonite/pulls/comments/53045135","id":53045135,"diff_hunk":"@@ -0,0 +1,161 @@\n+#![allow(unused_variables)]\n+use lexical::types::Types;\n+use syntax::expr::ExprWrapper;\n+use syntax::expr::Expr::*;\n+use semantic::analyzer_trait::ASTAnalyzer;\n+\n+pub struct TypeChecker;\n+\n+impl TypeChecker {\n+    pub fn new() -> TypeChecker {\n+        TypeChecker\n+    }\n+\n+    fn cmp_lhs_rhs(lhs_str: String, rhs_str: String) -> Option<String> {\n+        match (lhs_str.parse::<Types>(), rhs_str.parse::<Types>()) {\n+            (Ok(lhs_type), Ok(rhs_type)) => {\n+                if lhs_type != rhs_type {\n+                    panic!(\"Error goes here\"); // FIXME: Better errors\n+                }\n+\n+                Some(lhs_str)\n+            },\n+            (Err(()), Err(())) => {\n+                // TODO: Custom type comparison. May or may not be an error.\n+                panic!(\"Found a custom type references\");\n+            },\n+            // Found a builtin type and a custom type -> error\n+            _ => panic!(\"Error goes here\") // FIXME: Better errors\n+        }\n+    }\n+}\n+\n+impl ASTAnalyzer<Option<String>> for TypeChecker {\n+    fn analyze(&mut self, ast_root: &mut ExprWrapper) -> Option<String> {\n+        // TODO: Handle errors, Result<ExprWrapper, String>?\n+        // How to get Expr's type?\n+        // Basics:\n+        // Literal -> Builtin Type (Done) or Custom Type\n+        // Variable -> VarName -> Lookup VarDecl -> Type\n+        // FnCall -> FnName -> LookUp FnDecl -> Type\n+        // InfixOp -> analyze bubble up type from Expr op Expr\n+        // UnaryOp -> analyze bubble up type from Expr\n+\n+        // Future?:\n+        // if rust style let i = if a {} else {}\n+        // If needs lookup all returns in all possible code blocks, assert they're the same type\n+\n+        match *ast_root.get_mut_expr() {\n+            Assign(ref mut var_name_expr_wrapper, ref mut rhs_expr_wrapper) => {\n+                let lhs_type = match self.analyze(var_name_expr_wrapper) {","path":"src/semantic/type_checker.rs","position":50,"original_position":50,"commit_id":"259adad8e0d0e5631c143f86f346df972c962ea5","original_commit_id":"259adad8e0d0e5631c143f86f346df972c962ea5","user":{"login":"DanCardin","id":701548,"avatar_url":"https://avatars.githubusercontent.com/u/701548?v=3","gravatar_id":"","url":"https://api.github.com/users/DanCardin","html_url":"https://github.com/DanCardin","followers_url":"https://api.github.com/users/DanCardin/followers","following_url":"https://api.github.com/users/DanCardin/following{/other_user}","gists_url":"https://api.github.com/users/DanCardin/gists{/gist_id}","starred_url":"https://api.github.com/users/DanCardin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanCardin/subscriptions","organizations_url":"https://api.github.com/users/DanCardin/orgs","repos_url":"https://api.github.com/users/DanCardin/repos","events_url":"https://api.github.com/users/DanCardin/events{/privacy}","received_events_url":"https://api.github.com/users/DanCardin/received_events","type":"User","site_admin":false},"body":"unwrap_or for all of these? Slash, if you're just going to panic anyway","created_at":"2016-02-16T17:25:22Z","updated_at":"2016-02-16T17:25:22Z","html_url":"https://github.com/TheDan64/limonite/pull/41#discussion_r53045135","pull_request_url":"https://api.github.com/repos/TheDan64/limonite/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/TheDan64/limonite/pulls/comments/53045135"},"html":{"href":"https://github.com/TheDan64/limonite/pull/41#discussion_r53045135"},"pull_request":{"href":"https://api.github.com/repos/TheDan64/limonite/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/TheDan64/limonite/pulls/41","id":59281538,"html_url":"https://github.com/TheDan64/limonite/pull/41","diff_url":"https://github.com/TheDan64/limonite/pull/41.diff","patch_url":"https://github.com/TheDan64/limonite/pull/41.patch","issue_url":"https://api.github.com/repos/TheDan64/limonite/issues/41","number":41,"state":"open","locked":false,"title":"Basic Type Checker","user":{"login":"TheDan64","id":3749239,"avatar_url":"https://avatars.githubusercontent.com/u/3749239?v=3","gravatar_id":"","url":"https://api.github.com/users/TheDan64","html_url":"https://github.com/TheDan64","followers_url":"https://api.github.com/users/TheDan64/followers","following_url":"https://api.github.com/users/TheDan64/following{/other_user}","gists_url":"https://api.github.com/users/TheDan64/gists{/gist_id}","starred_url":"https://api.github.com/users/TheDan64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheDan64/subscriptions","organizations_url":"https://api.github.com/users/TheDan64/orgs","repos_url":"https://api.github.com/users/TheDan64/repos","events_url":"https://api.github.com/users/TheDan64/events{/privacy}","received_events_url":"https://api.github.com/users/TheDan64/received_events","type":"User","site_admin":false},"body":"Still needs a lot more work but provides basic local type checking. Also needs a lot more unit tests than the three in here.\r\n\r\nReorganizes code base. Provides a trait for semantic analysis sub-parts (though the parameters will likely change as SA gets further fleshed out)","created_at":"2016-02-13T23:36:27Z","updated_at":"2016-02-16T17:25:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3ea105126c09d1db46a4cf73330e77ce29efb263","assignee":{"login":"DanCardin","id":701548,"avatar_url":"https://avatars.githubusercontent.com/u/701548?v=3","gravatar_id":"","url":"https://api.github.com/users/DanCardin","html_url":"https://github.com/DanCardin","followers_url":"https://api.github.com/users/DanCardin/followers","following_url":"https://api.github.com/users/DanCardin/following{/other_user}","gists_url":"https://api.github.com/users/DanCardin/gists{/gist_id}","starred_url":"https://api.github.com/users/DanCardin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanCardin/subscriptions","organizations_url":"https://api.github.com/users/DanCardin/orgs","repos_url":"https://api.github.com/users/DanCardin/repos","events_url":"https://api.github.com/users/DanCardin/events{/privacy}","received_events_url":"https://api.github.com/users/DanCardin/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/TheDan64/limonite/pulls/41/commits","review_comments_url":"https://api.github.com/repos/TheDan64/limonite/pulls/41/comments","review_comment_url":"https://api.github.com/repos/TheDan64/limonite/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TheDan64/limonite/issues/41/comments","statuses_url":"https://api.github.com/repos/TheDan64/limonite/statuses/259adad8e0d0e5631c143f86f346df972c962ea5","head":{"label":"TheDan64:semantic_analysis","ref":"semantic_analysis","sha":"259adad8e0d0e5631c143f86f346df972c962ea5","user":{"login":"TheDan64","id":3749239,"avatar_url":"https://avatars.githubusercontent.com/u/3749239?v=3","gravatar_id":"","url":"https://api.github.com/users/TheDan64","html_url":"https://github.com/TheDan64","followers_url":"https://api.github.com/users/TheDan64/followers","following_url":"https://api.github.com/users/TheDan64/following{/other_user}","gists_url":"https://api.github.com/users/TheDan64/gists{/gist_id}","starred_url":"https://api.github.com/users/TheDan64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheDan64/subscriptions","organizations_url":"https://api.github.com/users/TheDan64/orgs","repos_url":"https://api.github.com/users/TheDan64/repos","events_url":"https://api.github.com/users/TheDan64/events{/privacy}","received_events_url":"https://api.github.com/users/TheDan64/received_events","type":"User","site_admin":false},"repo":{"id":21634794,"name":"limonite","full_name":"TheDan64/limonite","owner":{"login":"TheDan64","id":3749239,"avatar_url":"https://avatars.githubusercontent.com/u/3749239?v=3","gravatar_id":"","url":"https://api.github.com/users/TheDan64","html_url":"https://github.com/TheDan64","followers_url":"https://api.github.com/users/TheDan64/followers","following_url":"https://api.github.com/users/TheDan64/following{/other_user}","gists_url":"https://api.github.com/users/TheDan64/gists{/gist_id}","starred_url":"https://api.github.com/users/TheDan64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheDan64/subscriptions","organizations_url":"https://api.github.com/users/TheDan64/orgs","repos_url":"https://api.github.com/users/TheDan64/repos","events_url":"https://api.github.com/users/TheDan64/events{/privacy}","received_events_url":"https://api.github.com/users/TheDan64/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TheDan64/limonite","description":"Compiler for the Limonite programming language.","fork":false,"url":"https://api.github.com/repos/TheDan64/limonite","forks_url":"https://api.github.com/repos/TheDan64/limonite/forks","keys_url":"https://api.github.com/repos/TheDan64/limonite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheDan64/limonite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheDan64/limonite/teams","hooks_url":"https://api.github.com/repos/TheDan64/limonite/hooks","issue_events_url":"https://api.github.com/repos/TheDan64/limonite/issues/events{/number}","events_url":"https://api.github.com/repos/TheDan64/limonite/events","assignees_url":"https://api.github.com/repos/TheDan64/limonite/assignees{/user}","branches_url":"https://api.github.com/repos/TheDan64/limonite/branches{/branch}","tags_url":"https://api.github.com/repos/TheDan64/limonite/tags","blobs_url":"https://api.github.com/repos/TheDan64/limonite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheDan64/limonite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheDan64/limonite/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheDan64/limonite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheDan64/limonite/statuses/{sha}","languages_url":"https://api.github.com/repos/TheDan64/limonite/languages","stargazers_url":"https://api.github.com/repos/TheDan64/limonite/stargazers","contributors_url":"https://api.github.com/repos/TheDan64/limonite/contributors","subscribers_url":"https://api.github.com/repos/TheDan64/limonite/subscribers","subscription_url":"https://api.github.com/repos/TheDan64/limonite/subscription","commits_url":"https://api.github.com/repos/TheDan64/limonite/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheDan64/limonite/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheDan64/limonite/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheDan64/limonite/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheDan64/limonite/contents/{+path}","compare_url":"https://api.github.com/repos/TheDan64/limonite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheDan64/limonite/merges","archive_url":"https://api.github.com/repos/TheDan64/limonite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheDan64/limonite/downloads","issues_url":"https://api.github.com/repos/TheDan64/limonite/issues{/number}","pulls_url":"https://api.github.com/repos/TheDan64/limonite/pulls{/number}","milestones_url":"https://api.github.com/repos/TheDan64/limonite/milestones{/number}","notifications_url":"https://api.github.com/repos/TheDan64/limonite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheDan64/limonite/labels{/name}","releases_url":"https://api.github.com/repos/TheDan64/limonite/releases{/id}","deployments_url":"https://api.github.com/repos/TheDan64/limonite/deployments","created_at":"2014-07-09T01:20:13Z","updated_at":"2016-01-25T03:35:51Z","pushed_at":"2016-02-13T23:36:29Z","git_url":"git://github.com/TheDan64/limonite.git","ssh_url":"git@github.com:TheDan64/limonite.git","clone_url":"https://github.com/TheDan64/limonite.git","svn_url":"https://github.com/TheDan64/limonite","homepage":"","size":389,"stargazers_count":3,"watchers_count":3,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":3,"default_branch":"master"}},"base":{"label":"TheDan64:master","ref":"master","sha":"00b46f21b8e1eca1a0800f59692da9423da94104","user":{"login":"TheDan64","id":3749239,"avatar_url":"https://avatars.githubusercontent.com/u/3749239?v=3","gravatar_id":"","url":"https://api.github.com/users/TheDan64","html_url":"https://github.com/TheDan64","followers_url":"https://api.github.com/users/TheDan64/followers","following_url":"https://api.github.com/users/TheDan64/following{/other_user}","gists_url":"https://api.github.com/users/TheDan64/gists{/gist_id}","starred_url":"https://api.github.com/users/TheDan64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheDan64/subscriptions","organizations_url":"https://api.github.com/users/TheDan64/orgs","repos_url":"https://api.github.com/users/TheDan64/repos","events_url":"https://api.github.com/users/TheDan64/events{/privacy}","received_events_url":"https://api.github.com/users/TheDan64/received_events","type":"User","site_admin":false},"repo":{"id":21634794,"name":"limonite","full_name":"TheDan64/limonite","owner":{"login":"TheDan64","id":3749239,"avatar_url":"https://avatars.githubusercontent.com/u/3749239?v=3","gravatar_id":"","url":"https://api.github.com/users/TheDan64","html_url":"https://github.com/TheDan64","followers_url":"https://api.github.com/users/TheDan64/followers","following_url":"https://api.github.com/users/TheDan64/following{/other_user}","gists_url":"https://api.github.com/users/TheDan64/gists{/gist_id}","starred_url":"https://api.github.com/users/TheDan64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheDan64/subscriptions","organizations_url":"https://api.github.com/users/TheDan64/orgs","repos_url":"https://api.github.com/users/TheDan64/repos","events_url":"https://api.github.com/users/TheDan64/events{/privacy}","received_events_url":"https://api.github.com/users/TheDan64/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TheDan64/limonite","description":"Compiler for the Limonite programming language.","fork":false,"url":"https://api.github.com/repos/TheDan64/limonite","forks_url":"https://api.github.com/repos/TheDan64/limonite/forks","keys_url":"https://api.github.com/repos/TheDan64/limonite/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheDan64/limonite/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheDan64/limonite/teams","hooks_url":"https://api.github.com/repos/TheDan64/limonite/hooks","issue_events_url":"https://api.github.com/repos/TheDan64/limonite/issues/events{/number}","events_url":"https://api.github.com/repos/TheDan64/limonite/events","assignees_url":"https://api.github.com/repos/TheDan64/limonite/assignees{/user}","branches_url":"https://api.github.com/repos/TheDan64/limonite/branches{/branch}","tags_url":"https://api.github.com/repos/TheDan64/limonite/tags","blobs_url":"https://api.github.com/repos/TheDan64/limonite/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheDan64/limonite/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheDan64/limonite/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheDan64/limonite/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheDan64/limonite/statuses/{sha}","languages_url":"https://api.github.com/repos/TheDan64/limonite/languages","stargazers_url":"https://api.github.com/repos/TheDan64/limonite/stargazers","contributors_url":"https://api.github.com/repos/TheDan64/limonite/contributors","subscribers_url":"https://api.github.com/repos/TheDan64/limonite/subscribers","subscription_url":"https://api.github.com/repos/TheDan64/limonite/subscription","commits_url":"https://api.github.com/repos/TheDan64/limonite/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheDan64/limonite/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheDan64/limonite/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheDan64/limonite/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheDan64/limonite/contents/{+path}","compare_url":"https://api.github.com/repos/TheDan64/limonite/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheDan64/limonite/merges","archive_url":"https://api.github.com/repos/TheDan64/limonite/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheDan64/limonite/downloads","issues_url":"https://api.github.com/repos/TheDan64/limonite/issues{/number}","pulls_url":"https://api.github.com/repos/TheDan64/limonite/pulls{/number}","milestones_url":"https://api.github.com/repos/TheDan64/limonite/milestones{/number}","notifications_url":"https://api.github.com/repos/TheDan64/limonite/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheDan64/limonite/labels{/name}","releases_url":"https://api.github.com/repos/TheDan64/limonite/releases{/id}","deployments_url":"https://api.github.com/repos/TheDan64/limonite/deployments","created_at":"2014-07-09T01:20:13Z","updated_at":"2016-01-25T03:35:51Z","pushed_at":"2016-02-13T23:36:29Z","git_url":"git://github.com/TheDan64/limonite.git","ssh_url":"git@github.com:TheDan64/limonite.git","clone_url":"https://github.com/TheDan64/limonite.git","svn_url":"https://github.com/TheDan64/limonite","homepage":"","size":389,"stargazers_count":3,"watchers_count":3,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TheDan64/limonite/pulls/41"},"html":{"href":"https://github.com/TheDan64/limonite/pull/41"},"issue":{"href":"https://api.github.com/repos/TheDan64/limonite/issues/41"},"comments":{"href":"https://api.github.com/repos/TheDan64/limonite/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/TheDan64/limonite/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/TheDan64/limonite/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TheDan64/limonite/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/TheDan64/limonite/statuses/259adad8e0d0e5631c143f86f346df972c962ea5"}}}}