{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/11638","repository_url":"https://api.github.com/repos/dotnet/roslyn","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/11638/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/11638/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/11638/events","html_url":"https://github.com/dotnet/roslyn/issues/11638","id":157398624,"number":11638,"title":"Use of type initializer for optional parameters wrongfully compiles","user":{"login":"aevitas","id":151426,"avatar_url":"https://avatars.githubusercontent.com/u/151426?v=3","gravatar_id":"","url":"https://api.github.com/users/aevitas","html_url":"https://github.com/aevitas","followers_url":"https://api.github.com/users/aevitas/followers","following_url":"https://api.github.com/users/aevitas/following{/other_user}","gists_url":"https://api.github.com/users/aevitas/gists{/gist_id}","starred_url":"https://api.github.com/users/aevitas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aevitas/subscriptions","organizations_url":"https://api.github.com/users/aevitas/orgs","repos_url":"https://api.github.com/users/aevitas/repos","events_url":"https://api.github.com/users/aevitas/events{/privacy}","received_events_url":"https://api.github.com/users/aevitas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Compilers","name":"Area-Compilers","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Bug","name":"Bug","color":"fc2929"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Language-C%23","name":"Language-C#","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-29T18:21:26Z","updated_at":"2016-06-05T21:09:37Z","closed_at":null,"body":"While going over some code, I've come across an interesting piece of code that is underlined in red in Visual Studio, but does actually compile. The code is close to the following:\r\n\r\n        public static void Test(Vector3 vector = new Vector3() { X = 1f, Y = 1f, Z = 1f})\r\n        { }\r\n        \r\n        public struct Vector3\r\n        {\r\n            public float X;\r\n\r\n            public float Y;\r\n\r\n            public float Z;\r\n        }\r\n\r\nAs expected, when hovering the line, it reads:\r\n > Default parameter value for 'vector' must be compile-time constant\r\n\r\nAccording to the spec: \r\n\r\n>  The expression in a default-argument must be one of the following:\r\n* a constant-expression \r\n* **an expression of the form new S() where S is a value type**\r\n* an expression of the form default(S) where S is a value type\r\n\r\nThe above code doesn't fit any of these three, yet it does compile. When printing `vector` - the output is `0,0,0`.\r\n\r\nIs this intentional? Surely using the type initializer here should result in a compiler error?"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/223837816","html_url":"https://github.com/dotnet/roslyn/issues/11638#issuecomment-223837816","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/11638","id":223837816,"user":{"login":"gafter","id":3804346,"avatar_url":"https://avatars.githubusercontent.com/u/3804346?v=3","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"created_at":"2016-06-05T21:09:37Z","updated_at":"2016-06-05T21:09:37Z","body":"#11678 is a community-offered fix for this."}}
{"actor":{"display_login":"gafter"}}