{"action":"created","issue":{"url":"https://api.github.com/repos/elixir-lang/elixir/issues/3311","labels_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3311/labels{/name}","comments_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3311/comments","events_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3311/events","html_url":"https://github.com/elixir-lang/elixir/issues/3311","id":74098468,"number":3311,"title":"Syntax error in anonymous function declaration is reported as FunctionClauseError","user":{"login":"andreionut","id":1051275,"avatar_url":"https://avatars.githubusercontent.com/u/1051275?v=3","gravatar_id":"","url":"https://api.github.com/users/andreionut","html_url":"https://github.com/andreionut","followers_url":"https://api.github.com/users/andreionut/followers","following_url":"https://api.github.com/users/andreionut/following{/other_user}","gists_url":"https://api.github.com/users/andreionut/gists{/gist_id}","starred_url":"https://api.github.com/users/andreionut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreionut/subscriptions","organizations_url":"https://api.github.com/users/andreionut/orgs","repos_url":"https://api.github.com/users/andreionut/repos","events_url":"https://api.github.com/users/andreionut/events{/privacy}","received_events_url":"https://api.github.com/users/andreionut/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elixir-lang/elixir/labels/App:Elixir","name":"App:Elixir","color":"CCCCCC"},{"url":"https://api.github.com/repos/elixir-lang/elixir/labels/Kind:Bug","name":"Kind:Bug","color":"e10c02"},{"url":"https://api.github.com/repos/elixir-lang/elixir/labels/Level:Intermediate","name":"Level:Intermediate","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/elixir-lang/elixir/milestones/12","html_url":"https://github.com/elixir-lang/elixir/milestones/v1.1.0","labels_url":"https://api.github.com/repos/elixir-lang/elixir/milestones/12/labels","id":785442,"number":12,"title":"v1.1.0","description":"","creator":{"login":"josevalim","id":9582,"avatar_url":"https://avatars.githubusercontent.com/u/9582?v=3","gravatar_id":"","url":"https://api.github.com/users/josevalim","html_url":"https://github.com/josevalim","followers_url":"https://api.github.com/users/josevalim/followers","following_url":"https://api.github.com/users/josevalim/following{/other_user}","gists_url":"https://api.github.com/users/josevalim/gists{/gist_id}","starred_url":"https://api.github.com/users/josevalim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josevalim/subscriptions","organizations_url":"https://api.github.com/users/josevalim/orgs","repos_url":"https://api.github.com/users/josevalim/repos","events_url":"https://api.github.com/users/josevalim/events{/privacy}","received_events_url":"https://api.github.com/users/josevalim/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":38,"state":"open","created_at":"2014-09-10T20:33:19Z","updated_at":"2015-08-15T12:47:35Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2015-05-07T19:25:27Z","updated_at":"2015-08-16T07:10:29Z","closed_at":null,"body":"Elixir 1.0.4\r\nErlang/OTP 17\r\nMac OS X\r\n\r\nIf I make a syntax error when I declare an anonymous function, like use `=` instead of `->`, e.g.:\r\n\r\n```\r\nmy_fun = fn value = value end\r\n```\r\nI get this error:\r\n\r\n```\r\n** (FunctionClauseError) no function clause matching in :elixir_fn.expand/3\r\n    (elixir) src/elixir_fn.erl:31: :elixir_fn.expand([line: 4], {:=, [line: 4], [{{:value, [line: 4], nil}, {:index, [line: 4], nil}}, {:-, [line: 4], [{:value, [line: 4], nil}, {:index, [line: 4], nil}]}]}, %Macro.Env{aliases: [], context: nil, context_modules: [], export_vars: nil, file: \"iex\", function: nil, functions: [{Kernel, [!=: 2, !==: 2, *: 2, +: 1, +: 2, ++: 2, -: 1, -: 2, --: 2, /: 2, <: 2, <=: 2, ==: 2, ===: 2, =~: 2, >: 2, >=: 2, abs: 1, apply: 2, apply: 3, binary_part: 3, bit_size: 1, byte_size: 1, div: 2, elem: 2, exit: 1, function_exported?: 3, get_and_update_in: 3, get_in: 2, hd: 1, inspect: 1, inspect: 2, is_atom: 1, is_binary: 1, is_bitstring: 1, is_boolean: 1, is_float: 1, is_function: 1, is_function: 2, is_integer: 1, is_list: 1, is_map: 1, ...]}], lexical_tracker: nil, line: 1, local: IEx.Helpers, macro_aliases: [], macros: [{Kernel, [!: 1, &&: 2, ..: 2, <>: 2, @: 1, alias!: 1, and: 2, binding: 0, binding: 1, def: 1, def: 2, defdelegate: 2, defexception: 1, defimpl: 2, defimpl: 3, defmacro: 1, defmacro: 2, defmacrop: 1, defmacrop: 2, defmodule: 2, defoverridable: 1, defp: 1, defp: 2, defprotocol: 2, defstruct: 1, destructure: 2, get_and_update_in: 2, if: 2, in: 2, is_nil: 1, match?: 2, or: 2, put_in: 2, raise: 1, raise: 2, reraise: 2, reraise: 3, ...]}], module: nil, requires: [IEx.Helpers, Kernel, Kernel.Typespec], vars: [my_fun: nil]})\r\n    (elixir) src/elixir_exp.erl:10: :elixir_exp.expand/2\r\n```\r\n\r\nI would've expected a syntax error like `Unexpected token =`. Eg:\r\n\r\n```\r\niex(5)> my_fun = (fn value -> value )\r\n** (SyntaxError) iex:5: \"fn\" starting at line 5 is missing terminator \"end\". Unexpected token: )\r\n```\r\n\r\nInterestingly I get a different error for a different syntax error:\r\n```\r\niex(5)> my_fun = fn value => value end\r\n** (SyntaxError) iex:5: syntax error before: '=>'\r\n```\r\n\r\nI'm not familiar with the Elixir parser but if somebody can show me where it is, I might take a look."},"comment":{"url":"https://api.github.com/repos/elixir-lang/elixir/issues/comments/131496101","html_url":"https://github.com/elixir-lang/elixir/issues/3311#issuecomment-131496101","issue_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3311","id":131496101,"user":{"login":"jisaacstone","id":1398967,"avatar_url":"https://avatars.githubusercontent.com/u/1398967?v=3","gravatar_id":"","url":"https://api.github.com/users/jisaacstone","html_url":"https://github.com/jisaacstone","followers_url":"https://api.github.com/users/jisaacstone/followers","following_url":"https://api.github.com/users/jisaacstone/following{/other_user}","gists_url":"https://api.github.com/users/jisaacstone/gists{/gist_id}","starred_url":"https://api.github.com/users/jisaacstone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jisaacstone/subscriptions","organizations_url":"https://api.github.com/users/jisaacstone/orgs","repos_url":"https://api.github.com/users/jisaacstone/repos","events_url":"https://api.github.com/users/jisaacstone/events{/privacy}","received_events_url":"https://api.github.com/users/jisaacstone/received_events","type":"User","site_admin":false},"created_at":"2015-08-16T07:10:29Z","updated_at":"2015-08-16T07:10:29Z","body":"Report:\r\n\r\nBug seems to be [here](https://github.com/elixir-lang/elixir/blob/master/lib/elixir/src/elixir_parser.yrl#L227)\r\n\r\n    access_expr -> fn_eoe stab end_eoe : build_fn('$1', build_stab(reverse('$2'))).\r\n\r\n`value = value` is passed to `build_fn` as a `stab`. I could fix by adding a function clause:\r\n\r\n```erlang\r\nbuild_fn(Op, Stab) when is_tuple(Stab) ->\r\n  throw(meta_from_token(Op), \"Clearly that is an expression not a stab\", 'fn');\r\n```\r\n\r\nBut seems not the best. Maybe a bit of a hack.\r\n\r\nThe real problem seems to be [this line](https://github.com/elixir-lang/elixir/blob/master/lib/elixir/src/elixir_parser.yrl#L296)\r\n\r\n    stab_expr -> expr : '$1'.\r\n\r\nWhich, if I understand yecc correctly, says that all valid `expr"}}