{"action":"created","issue":{"url":"https://api.github.com/repos/MLstate/opalang/issues/170","labels_url":"https://api.github.com/repos/MLstate/opalang/issues/170/labels{/name}","comments_url":"https://api.github.com/repos/MLstate/opalang/issues/170/comments","events_url":"https://api.github.com/repos/MLstate/opalang/issues/170/events","html_url":"https://github.com/MLstate/opalang/issues/170","id":54782603,"number":170,"title":"A parse error is not exact","user":{"login":"Shiroy","id":1006143,"avatar_url":"https://avatars.githubusercontent.com/u/1006143?v=3","gravatar_id":"","url":"https://api.github.com/users/Shiroy","html_url":"https://github.com/Shiroy","followers_url":"https://api.github.com/users/Shiroy/followers","following_url":"https://api.github.com/users/Shiroy/following{/other_user}","gists_url":"https://api.github.com/users/Shiroy/gists{/gist_id}","starred_url":"https://api.github.com/users/Shiroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shiroy/subscriptions","organizations_url":"https://api.github.com/users/Shiroy/orgs","repos_url":"https://api.github.com/users/Shiroy/repos","events_url":"https://api.github.com/users/Shiroy/events{/privacy}","received_events_url":"https://api.github.com/users/Shiroy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-19T16:15:04Z","updated_at":"2015-01-19T16:41:12Z","closed_at":null,"body":"During my implementation of Birdy following the book, I encountered this error :\r\n````\r\nError: File \"src/model/user.opa\", line 96, characters 3-3, (96:3-96:3 | 2352-2352)\r\nParse error\r\n  The error may be in the following citation, usually in the red part\r\n  (starting at ⚐) or just before:\r\n\r\n}\r\n\t}\r\n\r\n\texposed function outcome(User.t, string) login(username, passwd)\r\n\t{\r\n\t\tx⚐ = ?/birdy/users[{username: username}]\r\n\r\n\t\tmatch(x){\r\n\t\t\tcase {none}: {failure: \"This user does not exist.\"}\r\n\t\t\tcase {some: user}:\r\n\t\r\nHint:\r\n  expected a returned expression at the end of the block, but found a binding. Did you mean `==' rather than `=' ?\r\n````\r\nBut this code is correct.\r\n\r\nThe problem was due to this line of code I mistype :\r\n````opa\r\nif(user.passwd = passwd) \r\n````\r\nWhich should be \r\n````opa\r\nif(user.passwd == passwd)\r\n````\r\nThe function is the same than in the book.\r\n\r\nThe error reporting should be improved because this report was not exact at all.\r\n\r\nPS : I work with the last version of OPA compiled for Linux.\r\n\r\n**The wrong code**\r\n````opa\r\nexposed function outcome(User.t, string) login(username, passwd)\r\n\t{\r\n\t\tx = ?/birdy/users[{username: username}]\r\n\r\n\t\tmatch(x){\r\n\t\t\tcase {none}: {failure: \"This user does not exist.\"}\r\n\t\t\tcase {some: user}:\r\n\t\t\t\tmatch(user.status)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase {activation_code: _}:\r\n\t\t\t\t\t\t{failure: \"This account is not activated.\"}\t\t\t\t\t\r\n\t\t\t\t\tcase {active} :\r\n\t\t\t\t\t\tif(user.passwd = passwd)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tuser_view = mk_view(user)\r\n\t\t\t\t\t\t\tUserContext.set(logged_user, {user: user_view})\r\n\t\t\t\t\t\t\t{success: user_view}\t\t\t\t\t\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t{failure: \"Incorrect password. Try again ;)\"}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t}\t\t\t\t\r\n\t\t}\r\n\t}\r\n````\r\n**The correct one**\r\n````opa\r\nexposed function outcome(User.t, string) login(username, passwd)\r\n\t{\r\n\t\tx = ?/birdy/users[{username: username}]\r\n\r\n\t\tmatch(x){\r\n\t\t\tcase {none}: {failure: \"This user does not exist.\"}\r\n\t\t\tcase {some: user}:\r\n\t\t\t\tmatch(user.status)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase {activation_code: _}:\r\n\t\t\t\t\t\t{failure: \"This account is not activated.\"}\t\t\t\t\t\r\n\t\t\t\t\tcase {active} :\r\n\t\t\t\t\t\tif(user.passwd == passwd)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tuser_view = mk_view(user)\r\n\t\t\t\t\t\t\tUserContext.set(logged_user, {user: user_view})\r\n\t\t\t\t\t\t\t{success: user_view}\t\t\t\t\t\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t{failure: \"Incorrect password. Try again ;)\"}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t}\t\t\t\t\r\n\t\t}\r\n\t}\r\n````"},"comment":{"url":"https://api.github.com/repos/MLstate/opalang/issues/comments/70523474","html_url":"https://github.com/MLstate/opalang/issues/170#issuecomment-70523474","issue_url":"https://api.github.com/repos/MLstate/opalang/issues/170","id":70523474,"user":{"login":"HenriChataing","id":5756004,"avatar_url":"https://avatars.githubusercontent.com/u/5756004?v=3","gravatar_id":"","url":"https://api.github.com/users/HenriChataing","html_url":"https://github.com/HenriChataing","followers_url":"https://api.github.com/users/HenriChataing/followers","following_url":"https://api.github.com/users/HenriChataing/following{/other_user}","gists_url":"https://api.github.com/users/HenriChataing/gists{/gist_id}","starred_url":"https://api.github.com/users/HenriChataing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HenriChataing/subscriptions","organizations_url":"https://api.github.com/users/HenriChataing/orgs","repos_url":"https://api.github.com/users/HenriChataing/repos","events_url":"https://api.github.com/users/HenriChataing/events{/privacy}","received_events_url":"https://api.github.com/users/HenriChataing/received_events","type":"User","site_admin":false},"created_at":"2015-01-19T16:41:12Z","updated_at":"2015-01-19T16:41:12Z","body":"The scope of the syntax error is generally too large (for example, it will return the entire block if only one binding has a typo). You can try improving the precision by commenting out the bindings one by one.\r\n\r\nAlso, be careful of the following pitfall: subsequent xhtml values will always be concatenated, which causes the following code to fail (with `expected a returned expression at the end of the block, but ...`):\r\n\r\n```opa\r\nxhtml = <div>Some xhtml value</div>\r\n<div id=\"container\">\r\n  {xhtml}\r\n</div>\r\n``` \r\n"}}