{"action":"opened","issue":{"url":"https://api.github.com/repos/fasterthanlime/rock/issues/875","labels_url":"https://api.github.com/repos/fasterthanlime/rock/issues/875/labels{/name}","comments_url":"https://api.github.com/repos/fasterthanlime/rock/issues/875/comments","events_url":"https://api.github.com/repos/fasterthanlime/rock/issues/875/events","html_url":"https://github.com/fasterthanlime/rock/issues/875","id":70964401,"number":875,"title":"'Func' objects behaving weirdly","user":{"login":"Allyally","id":1084881,"avatar_url":"https://avatars.githubusercontent.com/u/1084881?v=3","gravatar_id":"","url":"https://api.github.com/users/Allyally","html_url":"https://github.com/Allyally","followers_url":"https://api.github.com/users/Allyally/followers","following_url":"https://api.github.com/users/Allyally/following{/other_user}","gists_url":"https://api.github.com/users/Allyally/gists{/gist_id}","starred_url":"https://api.github.com/users/Allyally/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Allyally/subscriptions","organizations_url":"https://api.github.com/users/Allyally/orgs","repos_url":"https://api.github.com/users/Allyally/repos","events_url":"https://api.github.com/users/Allyally/events{/privacy}","received_events_url":"https://api.github.com/users/Allyally/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-25T20:35:08Z","updated_at":"2015-04-25T20:35:08Z","closed_at":null,"body":"Firstly, I had this short piece of code:\r\n```\r\nmyFunc: Func(Int)\r\nmyFunc_imp: func (i: Int) {\r\n\t\"%d\" printfln(i)\r\n}\r\nmain: func {\r\n\tmyFunc = myFunc_imp\r\n\tmyFunc(10)\r\n}\r\n```\r\nThe compiler throws a 'No such function' error on `myFunc(10)`, but can however, be worked around like this:\r\n```\r\nf := myFunc\r\nf(10)\r\n```\r\nWhich is just bizarre. Seems like it has difficulty with global Func objects.\r\n\r\nThe second issue is with Func objects as generic types. For example I can make an ArrayList of Func, but I cannot add items to it:\r\n```\r\nsaySomething: func {\r\n\t\"Hi!\" println()\r\n}\t\r\nmain: func {\r\n\tar := ArrayList<Func> new()\r\n\tar add(saySomething)\r\n}\r\n```\r\n\r\nThis also gives a 'No such function' error. This can be worked around with a container for that function:\r\n```\r\nFuncContainer: class <T> {\r\n\tf: Func(T)\r\n\tinit: func(=f)\r\n}\r\nsaySomething: func(i: Int) {\r\n\t\"%d\" printfln(i)\r\n}\r\nmain: func {\r\n\tfObj := FuncContainer<Int> new(saySomething)\r\n\tar := ArrayList<FuncContainer<Int>> new()\r\n\tar add(fObj)\r\n\tar get(0) f(12)\r\n}\r\n```\r\n\r\nThis compiles fine, but however it does not print 12, but instead '2686632'.\r\nAs @geckojsc put it \"I imagine the generic type bundles some extra information along with it making it incompatible with regular functions\"\r\n\r\nIt's also worth mentioning, this is only a problem with generic types. Change it to Int only functions, and it prints 12 just fine."}}