{"action":"created","issue":{"url":"https://api.github.com/repos/rxie25/PLT2016Spring/issues/102","repository_url":"https://api.github.com/repos/rxie25/PLT2016Spring","labels_url":"https://api.github.com/repos/rxie25/PLT2016Spring/issues/102/labels{/name}","comments_url":"https://api.github.com/repos/rxie25/PLT2016Spring/issues/102/comments","events_url":"https://api.github.com/repos/rxie25/PLT2016Spring/issues/102/events","html_url":"https://github.com/rxie25/PLT2016Spring/pull/102","id":153878919,"number":102,"title":"pendulm test","user":{"login":"rxie25","id":10619450,"avatar_url":"https://avatars.githubusercontent.com/u/10619450?v=3","gravatar_id":"","url":"https://api.github.com/users/rxie25","html_url":"https://github.com/rxie25","followers_url":"https://api.github.com/users/rxie25/followers","following_url":"https://api.github.com/users/rxie25/following{/other_user}","gists_url":"https://api.github.com/users/rxie25/gists{/gist_id}","starred_url":"https://api.github.com/users/rxie25/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxie25/subscriptions","organizations_url":"https://api.github.com/users/rxie25/orgs","repos_url":"https://api.github.com/users/rxie25/repos","events_url":"https://api.github.com/users/rxie25/events{/privacy}","received_events_url":"https://api.github.com/users/rxie25/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-09T21:54:41Z","updated_at":"2016-05-11T21:50:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rxie25/PLT2016Spring/pulls/102","html_url":"https://github.com/rxie25/PLT2016Spring/pull/102","diff_url":"https://github.com/rxie25/PLT2016Spring/pull/102.diff","patch_url":"https://github.com/rxie25/PLT2016Spring/pull/102.patch"},"body":"Currently cant pass."},"comment":{"url":"https://api.github.com/repos/rxie25/PLT2016Spring/issues/comments/218601047","html_url":"https://github.com/rxie25/PLT2016Spring/pull/102#issuecomment-218601047","issue_url":"https://api.github.com/repos/rxie25/PLT2016Spring/issues/102","id":218601047,"user":{"login":"jzacsh","id":156228,"avatar_url":"https://avatars.githubusercontent.com/u/156228?v=3","gravatar_id":"","url":"https://api.github.com/users/jzacsh","html_url":"https://github.com/jzacsh","followers_url":"https://api.github.com/users/jzacsh/followers","following_url":"https://api.github.com/users/jzacsh/following{/other_user}","gists_url":"https://api.github.com/users/jzacsh/gists{/gist_id}","starred_url":"https://api.github.com/users/jzacsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jzacsh/subscriptions","organizations_url":"https://api.github.com/users/jzacsh/orgs","repos_url":"https://api.github.com/users/jzacsh/repos","events_url":"https://api.github.com/users/jzacsh/events{/privacy}","received_events_url":"https://api.github.com/users/jzacsh/received_events","type":"User","site_admin":false},"created_at":"2016-05-11T21:50:37Z","updated_at":"2016-05-11T21:50:37Z","body":"@nnhoang this is now down to a bug in the `sast`, where `theta` is not correctly made available where it is needed.\r\n\r\n**tl;dr** i believe the original design tianci and i discussed would solve this problem: treat known values like macros _(or in the case of values that are themselves zero-parameter functions - just always call the function **instead** of the variable)_\r\n\r\n## `codegen.ml` bug description\r\n\r\n`$ clang-format -i ./tests/test-pendulum.c && less -N ./tests/test-pendulum.c` produces:\r\nMake special note of line 11 referring to a `theta` that is stored on the stack in a different scope _(line 29)_\r\n\r\n```c\r\n 1 #include <math.h>\r\n 2 #include <stdio.h>\r\n 3 double Global_sum_0() { return (double)(0.); }\r\n 4\r\n 5 double Pendulum_m_0() { return (double)(10.); }\r\n 6\r\n 7 double Pendulum_theta_1() { return (double)(3.14 / 2.); }\r\n 8\r\n 9 double Pendulum_g_2() { return (double)(9.8); }\r\n10\r\n11 double Pendulum_h_3(double l) { return (double)(l - l * cos(theta)); }\r\n12\r\n13 double Pendulum_v_4(double h) { return (double)(pow(2. * g * h, 1. / 2.)); }\r\n14\r\n15 double Pendulum_sum_5() { return (double)(0.); }\r\n16\r\n17 double Pendulum_sum_6() { return (double)(0.); }\r\n18 void find_Pendulum_0(double l) {\r\n19   double v;\r\n20   double theta;\r\n21   double sum;\r\n22   double m;\r\n23   double h;\r\n24   double g;\r\n25\r\n26   h = Pendulum_h_3(l);\r\n27   v = Pendulum_v_4(h);\r\n28\r\n29   theta = Pendulum_theta_1();\r\n30\r\n31   sum = Pendulum_sum_5();\r\n32\r\n33   m = Pendulum_m_0();\r\n34\r\n35   h = Pendulum_h_3(l);\r\n36\r\n37   g = Pendulum_g_2();\r\n38\r\n39   printf(\"velocity: %f\", (double)(v));\r\n40 }\r\n41\r\n42 void find_Pendulum_0_range() {\r\n43   double l;\r\n44   for (l = 0; l <= 5.000000; l++) {\r\n45     find_Pendulum_0(l);\r\n46   }\r\n47 }\r\n48 int main() {\r\n49   find_Pendulum_0_range();\r\n50   return 0;\r\n51 }\r\n```"}}