dotnet / dotnet/fsharp

Cannot use array/list/etc literals in attribute parameters

Open
#7,916 1 comment 9 reactions 0 assignees View on GitHub
Feature Improvement
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

The following code fails to compile:

```fsharp
open System
open Xunit

[]
[]
let banana (x, y, maybe, arr) = ()
```

This is because array literals are not considered constants for the purposes of attribute checking: https://github.com/dotnet/fsharp/blob/9be86c23a9540c41929ff3dbcd904d069ba34a34/src/fsharp/PostInferenceChecks.fs#L1589-L1613

Although not idiomatic F#, this pattern exists in multiple test frameworks (NUnit has the same feature) and should probably typecheck, considering it is allowed in C#.

From: https://twitter.com/ploeh/status/1200096980275519489

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.