Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow attributes on type extensions #7481

Merged
merged 5 commits into from
Sep 4, 2019

Conversation

nelson-wu
Copy link
Contributor

@nelson-wu nelson-wu commented Sep 3, 2019

Fixes #7394

Before, when attributes get added to type extensions, they can be parsed, no errors are thrown, but the attributes are silently dropped inside the type checker. This PR explicitly disallows that.

@dnfclas
Copy link

dnfclas commented Sep 3, 2019

CLA assistant check
All CLA requirements met.

@nelson-wu nelson-wu marked this pull request as ready for review September 3, 2019 22:53
@nelson-wu
Copy link
Contributor Author

@KevinRansom @dsyme Could you guys take a look at this PR?

Copy link
Contributor

@dsyme dsyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Perhaps change the error text to "Attributes cannot be applied to type extensions"

@KevinRansom
Copy link
Member

KevinRansom commented Sep 4, 2019

@nelson-wu, can you change the error message per @dsyme, then I will merge the change.

Thanks

Kevin

@nelson-wu
Copy link
Contributor Author

@KevinRansom @dsyme Thanks for the review! I've made the changes

@KevinRansom
Copy link
Member

@nelson-wu, thanks mate, when it goes green, I'll merge it.

@cartermp cartermp merged commit 49eeb63 into dotnet:master Sep 4, 2019
@@ -16429,6 +16429,11 @@ module TcDeclarations =
if not (isNil members) && tcref.IsTypeAbbrev then
errorR(Error(FSComp.SR.tcTypeAbbreviationsCannotHaveAugmentations(), tyDeclRange))

let (ComponentInfo (attributes, _, _, _, _, _, _, _)) = synTyconInfo
if not (List.isEmpty attributes) && (declKind = ExtrinsicExtensionBinding || declKind = IntrinsicExtensionBinding) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
* add test for feature

* add error logic to typechecker

* update strings

* address comments

* update tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arbitrary nonsense attributes can be added to type extensions
6 participants