-
Notifications
You must be signed in to change notification settings - Fork 802
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
Type-mismatched [<DefaultParameterValue>] is not ignored enough #18314
Comments
It should behave as if using any other mismatched type annotation, indeed. |
Figured out what is happening - the method is indeed typechecked as one without optional arguments, but the I will check if there are some places which intentionally relly on having a |
If you remove the attributes, it stops producing the |
Ah, the optional parameter was a red herring then. Thank you for investigating this! Do you know of a way that would make Otherwise we can close this. |
I will check if we couldn't expand the warnings on implicit conversions. I am certain there will be hypothetical use cases for which a full error would be a breaking change, but I believe a warning should be acceptable. |
There is an inconsistency in how an incorrect placement of
[<DefaultParameterValue>]
is handled. Usually, in most situations, the parameter is simply not treated as optional at all, but if it is of typeobj
, it seems it is still considered optional.Repro steps
Expected behavior
C.Foo()
should fail to compile, since the attribute has mismatched type and thus even[<Optional>]
is ignored.Actual behavior
The code compiles and passes
null
toFoo
, in contrary to the warning:Known workarounds
Providing a different type than
obj
(as far as I can tell) correctly stops the code from being compilable at all.Related information
Environment: https://sharplab.io/#v2:DYLgZgzgPg9gDgUwHYAIDKBPCAXBBbAOgCUBXJbASzwQIElyEAneNJgNwoGMEIBYAKAHYMiFAGEUAXgEoUOAIaVOKangBGTFADEYMABQBtADwB5OJRhJ5wAHwBdYwBEEYeSWDYACvMbzquRgA1axIEPQAiAAsEYGAYcIBKexQYNQArEBT0hKkZWRQ4RgpyMFRwgFIAQXCstIEBMQIdfQSgA=
The text was updated successfully, but these errors were encountered: