{"action":"created","issue":{"url":"https://api.github.com/repos/inkle/ink/issues/52","repository_url":"https://api.github.com/repos/inkle/ink","labels_url":"https://api.github.com/repos/inkle/ink/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/inkle/ink/issues/52/comments","events_url":"https://api.github.com/repos/inkle/ink/issues/52/events","html_url":"https://github.com/inkle/ink/issues/52","id":146376392,"number":52,"title":"Parameter coersion fails for externally bound function of type Action<string,int>","user":{"login":"nullObjectPtr","id":11605299,"avatar_url":"https://avatars.githubusercontent.com/u/11605299?v=3","gravatar_id":"","url":"https://api.github.com/users/nullObjectPtr","html_url":"https://github.com/nullObjectPtr","followers_url":"https://api.github.com/users/nullObjectPtr/followers","following_url":"https://api.github.com/users/nullObjectPtr/following{/other_user}","gists_url":"https://api.github.com/users/nullObjectPtr/gists{/gist_id}","starred_url":"https://api.github.com/users/nullObjectPtr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nullObjectPtr/subscriptions","organizations_url":"https://api.github.com/users/nullObjectPtr/orgs","repos_url":"https://api.github.com/users/nullObjectPtr/repos","events_url":"https://api.github.com/users/nullObjectPtr/events{/privacy}","received_events_url":"https://api.github.com/users/nullObjectPtr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-06T17:10:08Z","updated_at":"2016-04-06T20:13:03Z","closed_at":null,"body":"Having some trouble with external function binding. I was able to get a function of type Action<int> to work, but another one of type Action<string,int> is throwing exceptions when called. Specifically \"failed to cast string to int32\". There may be function signatures that will trigger this but I have not explored any other combinations.\r\n\r\nMinimal example provided below\r\n\r\nCheers, \r\n-Jonathan\r\n\r\nInk File:\r\n```\r\nEXTERNAL grow_apples(amount)\r\nEXTERNAL give_apples_to(id, amount)\r\n\r\n-> Begin\r\n\r\n== Begin ==\r\n{grow_apples(4)}\r\n{give_apples_to(\"beth\", 4)}\r\n-> DONE\r\n```\r\n\r\nMinInkExample.cs with compiled story inlined\r\n```\r\nusing System;\r\nusing Ink.Runtime;\r\n\r\npublic class MinInkExample : object\r\n{\r\n    private string storyText = @\"{\"\"inkVersion\"\":11,\"\"root\"\":[[{\"\"->\"\":\"\"Begin\"\"},null],\"\"done\"\",{\"\"Begin\"\":[[[\"\"G>\"\",[\"\"ev\"\",[4,{\"\"x()\"\":\"\"grow_apples\"\",\"\"exArgs\"\":1},null],\"\"out\"\",\"\"/ev\"\",null],\"\"G<\"\",null],\"\"\\n\"\",[\"\"G>\"\",[\"\"ev\"\",[\"\"str\"\",\"\"^beth\"\",\"\"/str\"\",4,{\"\"x()\"\":\"\"give_apples_to\"\",\"\"exArgs\"\":2},null],\"\"out\"\",\"\"/ev\"\",null],\"\"G<\"\",null],\"\"\\n\"\",\"\"done\"\",null],null]}]}\";\r\n    public MinInkExample()\r\n    {\r\n        Story s = new Story(storyText);\r\n        s.BindExternalFunction(\"grow_apples\", new Action<int>(GrowApples));\r\n        s.BindExternalFunction(\"give_apples_to\", new Action<string, int>(GiveApplesTo));\r\n        s.ContinueMaximally();\r\n    }\r\n\r\n    // OK\r\n    private void GrowApples(int howMany)\r\n    {\r\n        string msg = \"you grow \" + howMany + \" apples.\";\r\n    }\r\n\r\n    // Throws: System.Exception: Failed to cast String to Int32\r\n    private void GiveApplesTo(string who, int howMany)\r\n    {\r\n        string msg = who + \" has \" + howMany + \" apples.\";\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/inkle/ink/issues/comments/206539771","html_url":"https://github.com/inkle/ink/issues/52#issuecomment-206539771","issue_url":"https://api.github.com/repos/inkle/ink/issues/52","id":206539771,"user":{"login":"nullObjectPtr","id":11605299,"avatar_url":"https://avatars.githubusercontent.com/u/11605299?v=3","gravatar_id":"","url":"https://api.github.com/users/nullObjectPtr","html_url":"https://github.com/nullObjectPtr","followers_url":"https://api.github.com/users/nullObjectPtr/followers","following_url":"https://api.github.com/users/nullObjectPtr/following{/other_user}","gists_url":"https://api.github.com/users/nullObjectPtr/gists{/gist_id}","starred_url":"https://api.github.com/users/nullObjectPtr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nullObjectPtr/subscriptions","organizations_url":"https://api.github.com/users/nullObjectPtr/orgs","repos_url":"https://api.github.com/users/nullObjectPtr/repos","events_url":"https://api.github.com/users/nullObjectPtr/events{/privacy}","received_events_url":"https://api.github.com/users/nullObjectPtr/received_events","type":"User","site_admin":false},"created_at":"2016-04-06T20:13:03Z","updated_at":"2016-04-06T20:13:03Z","body":"I can certainly work around, but the the source of the bug could be a larger issue, say for instance, an error in the parser. I'll poke around source and see what the cause may be when I get some time later in the week.  "}}