Last active
February 10, 2019 20:46
-
-
Save jskripsky/428a972813952360d420655cc470594d to your computer and use it in GitHub Desktop.
F# compiler bug: attributes on type aliases are silently ignored.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
[<AttributeUsage(AttributeTargets.Class)>] | |
type DocAttribute (text: string) = | |
inherit Attribute() | |
member x.Text = text | |
[<Doc "Attribute on Test">] | |
type Test = { | |
i: int | |
} | |
// this should cause an error. | |
// | |
// https://github.com/Microsoft/visualfsharp/blob/f1558b7f24c7e6bbf284c428dbf9ec41bda877e1/src/fsharp/pars.fsy#L2037 | |
// type Test' = [<Doc "Attribute on Test prime">] Test | |
[<Doc "Attribute on Test prime">] | |
type Test' = Test | |
module Check = | |
let docTextOnTestPrime = | |
let t = typeof<Test'> | |
let attrs = t.GetCustomAttributes(typeof<DocAttribute>, false) | |
(attrs.[0] :?> DocAttribute).Text | |
// https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/pars.fsy#L1439 (type def) | |
// https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/pars.fsy#L1444 | |
// http://ratatosk.dynu.net/ast/#?code=PYBwpgdgBAygngZwC5gLYCh0G0A8BBJJAJwEsAjAVxQFUEBDAczAAoDjyqwAVOoppBADoAwgBs6CBAEoAfAF10SOOCgARYAGM2pSiijMUADyQAuKMlIQGUqAF50UR1BIQAFmFJIo2jimZSHJ1Q0Mg8oQ0EuMGM7KCMkTFx1DSgAIh9dMChgaCjkVPlFZSy8r1soAG9AxxIzFwSAX0wAema41xIEc1dgClEAEygNOgoELLpoDyJgIkF0Vvm210IQBBNWhhIkVwoyQQ1gVGaAWRINaYRgADMkZoA3Too6USuEV14QZrJRYDJmq4AjABWIEADjIAHYrgAmAAsGghYAAbGQyDDQfDYdDQf00QBOMAaWEAsj9OigiGIgHNBBEDT-N4fZogXhCV5wADEABloQAGADMEMWcWKUFKAHJYklNGkMpxsrkwMgoCBSMECnIxUqEtgcMlZYQdPKclrlaqSOrCkoVBLYqVEnqZelDb4sibSiq1WANUUbdrxZLyhUoP0KKhUHA6hAvE0gA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment