{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/4287","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/4287/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/4287/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/4287/events","html_url":"https://github.com/rust-lang/rust/issues/4287","id":9509811,"number":4287,"title":"Better error message for polymorphic recursion","user":{"login":"migmit","id":2890201,"avatar_url":"https://avatars.githubusercontent.com/u/2890201?v=3","gravatar_id":"","url":"https://api.github.com/users/migmit","html_url":"https://github.com/migmit","followers_url":"https://api.github.com/users/migmit/followers","following_url":"https://api.github.com/users/migmit/following{/other_user}","gists_url":"https://api.github.com/users/migmit/gists{/gist_id}","starred_url":"https://api.github.com/users/migmit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/migmit/subscriptions","organizations_url":"https://api.github.com/users/migmit/orgs","repos_url":"https://api.github.com/users/migmit/repos","events_url":"https://api.github.com/users/migmit/events{/privacy}","received_events_url":"https://api.github.com/users/migmit/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-diagnostics","name":"A-diagnostics","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-typesystem","name":"A-typesystem","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/I-papercut","name":"I-papercut","color":"e10c02"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/P-low","name":"P-low","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2012-12-25T10:54:25Z","updated_at":"2016-05-02T12:02:28Z","closed_at":null,"body":"Can't compile:\r\n```\r\nenum Nil {Nil}\r\nstruct Cons<T> {head:int, tail:T}\r\ntrait Dot {fn dot(other:self) -> int;}\r\nimpl Nil:Dot {\r\n  fn dot(_:Nil) -> int {0}\r\n}\r\nimpl<T:Dot> Cons<T>:Dot {\r\n  fn dot(other:Cons<T>) -> int {\r\n    self.head * other.head + self.tail.dot(other.tail)\r\n  }\r\n}\r\nfn test<T:Dot> (n:int, i:int, first:T, second:T) ->int {\r\n  match n {\r\n    0 => {first.dot(second)}\r\n    _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}\r\n  }\r\n}\r\nfn main() {\r\n  let n = test(5, 0, Nil, Nil);\r\n  io::println(fmt!(\"%d\", n));\r\n}\r\n```\r\nSame code in Java, C# or Haskell works."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/216218817","html_url":"https://github.com/rust-lang/rust/issues/4287#issuecomment-216218817","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/4287","id":216218817,"user":{"login":"birkenfeld","id":144359,"avatar_url":"https://avatars.githubusercontent.com/u/144359?v=3","gravatar_id":"","url":"https://api.github.com/users/birkenfeld","html_url":"https://github.com/birkenfeld","followers_url":"https://api.github.com/users/birkenfeld/followers","following_url":"https://api.github.com/users/birkenfeld/following{/other_user}","gists_url":"https://api.github.com/users/birkenfeld/gists{/gist_id}","starred_url":"https://api.github.com/users/birkenfeld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birkenfeld/subscriptions","organizations_url":"https://api.github.com/users/birkenfeld/orgs","repos_url":"https://api.github.com/users/birkenfeld/repos","events_url":"https://api.github.com/users/birkenfeld/events{/privacy}","received_events_url":"https://api.github.com/users/birkenfeld/received_events","type":"User","site_admin":false},"created_at":"2016-05-02T12:02:28Z","updated_at":"2016-05-02T12:02:28Z","body":"New (and sole) message in nightly:\r\n```\r\n<anon>:12:1: 17:2 error: reached the recursion limit while instantiating `test::<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Cons<Nil>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`\r\n<anon>:12 fn test<T:Dot> (n: i32, i: i32, first: T, second: T) ->i32 {\r\n<anon>:13   match n {\r\n<anon>:14     0 => {first.dot(second)}\r\n<anon>:15     _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}\r\n<anon>:16   }\r\n<anon>:17 }\r\n```\r\nNot pretty, but much better than before. Fixed?"}}