Skip to content

Commit

Permalink
revert to stable warning when arg is other than obj
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Gro committed Feb 24, 2025
1 parent d217778 commit a1a370b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
2 changes: 0 additions & 2 deletions src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9787,8 +9787,6 @@ and GetNewInferenceTypeForMethodArg (cenv: cenv) x =
| SynExpr.Quote (_, raw, a, _, _) ->
if raw then cont (0, mkRawQuotedExprTy g)
else loopExpr a (cont << fun struct (depth, ty) -> depth + 1, mkQuotedExprTy g ty)
| SynExpr.Const (SynConst.Unit, _) ->
cont (0, g.unit_ty)
| _ -> cont (0, NewInferenceType g)

let struct (_depth, ty) = loopExpr x id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ module CustomAttributes_Basic =
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 193, Line 10, Col 3, Line 10, Col 59, """Type constraint mismatch. The type
'unit'
is not compatible with type
'int array'
""")
(Error 1, Line 10, Col 3, Line 10, Col 59, "This expression was expected to have type\n 'int array' \nbut here has type\n 'unit' ")
(Error 267, Line 10, Col 3, Line 10, Col 59, "This is not a valid constant expression or custom attribute value")
(Error 850, Line 10, Col 3, Line 10, Col 59, "This attribute cannot be used in this version of F#")
(Error 850, Line 13, Col 3, Line 13, Col 101, "This attribute cannot be used in this version of F#")
(Error 850, Line 16, Col 3, Line 16, Col 50, "This attribute cannot be used in this version of F#")
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ module MemberDefinitions_OptionalDefaultParamArgs =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics
[(Error 193, Line 13, Col 18, Line 13, Col 20, "Type constraint mismatch. The type
'unit'
is not compatible with type
'int'
")]
|> withDiagnostics [
(Error 1, Line 13, Col 18, Line 13, Col 20, "This expression was expected to have type\n 'int' \nbut here has type\n 'unit' ")
]

// SOURCE=InterfaceMethod.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"InterfaceMethod.fs"|])>]
Expand Down Expand Up @@ -80,12 +77,11 @@ module MemberDefinitions_OptionalDefaultParamArgs =
|> verifyCompile
|> shouldFail
|> withDiagnostics
[(Warning 3211, Line 10, Col 62, Line 10, Col 63, "The default value does not have the same type as the argument. The DefaultParameterValue attribute and any Optional attribute will be ignored. Note: 'null' needs to be annotated with the correct type, e.g. 'DefaultParameterValue(null:obj)'.");
(Error 193, Line 13, Col 25, Line 13, Col 27, "Type constraint mismatch. The type
'unit'
is not compatible with type
'string'
")]
[ Warning 3211, Line 10, Col 62, Line 10, Col 63, "The default value does not have the same type as the argument. The DefaultParameterValue attribute and any Optional attribute will be ignored. Note: 'null' needs to be annotated with the correct type, e.g. 'DefaultParameterValue(null:obj)'."
Error 1, Line 13, Col 25, Line 13, Col 27, "This expression was expected to have type
'string'
but here has type
'unit' "]

[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_WrongDefaultObj.fs"|])>]
let ``W_WrongDefaultObjType_fs`` compilation =
Expand Down

0 comments on commit a1a370b

Please sign in to comment.