Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Fixed how the source ranges of warn directives are reported (as trivia) in the parser output (by not reporting leading spaces). ([Issue #19405](https://github.com/dotnet/fsharp/issues/19405), [PR #19408]((https://github.com/dotnet/fsharp/pull/19408)))
* Fix UoM value type `ToString()` returning garbage values when `--checknulls+` is enabled, caused by double address-taking in codegen. ([Issue #19435](https://github.com/dotnet/fsharp/issues/19435), [PR #19440](https://github.com/dotnet/fsharp/pull/19440))
* Fix completion inconsistently showing some obsolete members (fields and events) while hiding others (methods and properties). All obsolete members are now consistently hidden by default. ([Issue #13512](https://github.com/dotnet/fsharp/issues/13512), [PR #19506](https://github.com/dotnet/fsharp/pull/19506))
* Fix internal error `FS0192: encodeCustomAttrElemType` when using an empty array of user-defined type as a custom attribute argument (e.g. `[<DefaultValue([||] : A[])>]`). Empty arrays of arbitrary types are now encoded using `System.Object` as the element type. ([Issue #12796](https://github.com/dotnet/fsharp/issues/12796), [PR #19472](https://github.com/dotnet/fsharp/pull/19472))

### Added

Expand Down
24 changes: 22 additions & 2 deletions src/Compiler/CodeGen/IlxGen.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10182,7 +10182,7 @@ and EmitRestoreStack cgbuf (savedStack, savedStackLocals) =
//GenAttr: custom attribute generation
//-------------------------------------------------------------------------

and GenAttribArg amap g eenv x (ilArgTy: ILType) =
and GenAttribArg amap (g: TcGlobals) eenv x (ilArgTy: ILType) =

match stripDebugPoints x, ilArgTy with
// Detect 'null' used for an array argument
Expand Down Expand Up @@ -10222,7 +10222,27 @@ and GenAttribArg amap g eenv x (ilArgTy: ILType) =
// Detect '[| ... |]' nodes
| Expr.Op(TOp.Array, [ elemTy ], args, m), _ ->
let ilElemTy = GenType amap m eenv.tyenv elemTy
ILAttribElem.Array(ilElemTy, List.map (fun arg -> GenAttribArg amap g eenv arg ilElemTy) args)

// Check if element type can be encoded in custom attribute metadata (ECMA 335).
// Valid element types: primitives, enums, string, System.Type, System.Object.
let isUnencodableBoxedElemType =
match ilElemTy with
| ILType.Boxed tspec when
tspec.Name <> "System.String"
&& tspec.Name <> "System.Object"
&& tspec.Name <> "System.Type"
->
true
| _ -> false

if isUnencodableBoxedElemType then
if args.IsEmpty then
// Empty arrays: substitute System.Object as element type since no elements need encoding.
ILAttribElem.Array(g.ilg.typ_Object, [])
else
error (Error(FSComp.SR.ilCustomAttrInvalidArrayElemType (ilElemTy.TypeRef.Name), m))
else
ILAttribElem.Array(ilElemTy, List.map (fun arg -> GenAttribArg amap g eenv arg ilElemTy) args)

// Detect 'typeof<ty>' calls
| TypeOfExpr g ty, _ -> ILAttribElem.Type(Some(GenType amap x.Range eenv.tyenv ty))
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1814,3 +1814,4 @@ featurePreprocessorElif,"#elif preprocessor directive"
3882,lexHashElifMustBeFirst,"#elif directive must appear as the first non-whitespace character on a line"
3883,lexHashElifMustHaveIdent,"#elif directive should be immediately followed by an identifier"
3884,tcFunctionValueUsedAsInterpolatedStringArg,"This expression is a function value. When used in an interpolated string it will be formatted using its 'ToString' method, which is likely not the intended behavior. Consider applying the function to its arguments."
3885,ilCustomAttrInvalidArrayElemType,"The type '%s' is not a valid custom attribute argument type. Custom attribute arrays must have elements of primitive types, enums, string, System.Type, or System.Object."
9 changes: 7 additions & 2 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/Compiler/xlf/FSComp.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/Compiler/xlf/FSComp.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading