{"action":"opened","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/4666","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/4666/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/4666/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/4666/events","html_url":"https://github.com/crystal-lang/crystal/issues/4666","id":240257454,"number":4666,"title":"Tuple-expansion with nil to vararg lib function crashes compiler","user":{"login":"Papierkorb","id":737062,"avatar_url":"https://avatars0.githubusercontent.com/u/737062?v=3","gravatar_id":"","url":"https://api.github.com/users/Papierkorb","html_url":"https://github.com/Papierkorb","followers_url":"https://api.github.com/users/Papierkorb/followers","following_url":"https://api.github.com/users/Papierkorb/following{/other_user}","gists_url":"https://api.github.com/users/Papierkorb/gists{/gist_id}","starred_url":"https://api.github.com/users/Papierkorb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Papierkorb/subscriptions","organizations_url":"https://api.github.com/users/Papierkorb/orgs","repos_url":"https://api.github.com/users/Papierkorb/repos","events_url":"https://api.github.com/users/Papierkorb/events{/privacy}","received_events_url":"https://api.github.com/users/Papierkorb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-03T20:18:03Z","updated_at":"2017-07-03T20:18:03Z","closed_at":null,"body":"Hello,\r\n\r\nWhen expanding a tuple containing a `nil` into a `lib` vararg function, the compiler crashes with an invalid memory access.\r\n\r\nThe following code crashes the compiler (See below):\r\n\r\n```crystal\r\nlib Foo\r\n  # Some vararg function\r\n  fun bar(baz : Int32, ...) : Int32\r\nend\r\n\r\ndef fwd(*arguments)\r\n  Foo.bar(*arguments) # Expand argument tuple with nil\r\nend\r\n\r\nfwd(1, nil) # Crashes\r\n# Foo.bar(*{1, nil}) # Crashes\r\n# Foo.bar(1, nil) # Works fine\r\n# fwd(1, 2) # Works fine\r\n```\r\n\r\n## Compiler log\r\n\r\n```\r\nInvalid memory access (signal 11) at address 0x0\r\n[0x43cebf] __crystal_sigfault_handler +63\r\n[0x7fe9578c6940] ???\r\n[0x7fe958ebeee4] _ZN4llvm11PointerType3getEPNS_4TypeEj +20\r\n[0x7fe958dea911] _ZN4llvm25ConstantFoldGetElementPtrEPNS_4TypeEPNS_8ConstantEbNS_8OptionalIjEENS_8ArrayRefIPNS_5ValueEEE +1937\r\n[0x7fe958e07471] _ZN4llvm12ConstantExpr16getGetElementPtrEPNS_4TypeEPNS_8ConstantENS_8ArrayRefIPNS_5ValueEEEbNS_8OptionalIjEES2_ +113\r\n[0x7fe958e1333b] LLVMBuildInBoundsGEP +619\r\n[0x133c426] ???\r\n[0x13a7a63] ???\r\n[0x139a91c] ???\r\n[0x1364a7e] ???\r\n[0x1364e26] ???\r\n[0x1386c93] ???\r\n[0x138d294] ???\r\n[0x139c799] ???\r\n[0x1364a7e] ???\r\n[0x1364e26] ???\r\n[0x12fc8ad] ???\r\n[0x1b92f85] ???\r\n[0x1c372e9] ???\r\n[0x475dfd] ???\r\n[0x43c7ed] main +18909\r\n[0x7fe956cc343a] __libc_start_main +234\r\n[0x4097da] _start +42\r\n[0x0] ???\r\n```\r\n\r\n**Platform**: `Crystal 0.22.0 (2017-04-22) LLVM 4.0.0` on `ArchLinux x64`\r\n\r\nThanks."}}
{"actor":{"display_login":"Papierkorb"}}