Skip to content

FS0267 trying to concatenate string in an attribute value with --checked+ #11398

@emz00

Description

@emz00

Repro steps

Try to compile the following program. Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <OtherFlags>--checked+</OtherFlags>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>
 
</Project>

Program.fs:

open System.ComponentModel

[<EntryPoint>]
[<System.ComponentModel.DefaultValue("test" + "ing")>]
let main argv =
    0

Expected behavior

It compiles successfully, just as it does without --checked+

Actual behavior

Compiler error on the [<System.ComponentModel.DefaultValue("test" + "ing")>] line:

Program.fs(4,16): error FS0267: This is not a valid constant expression or custom attribute value

Known workarounds

None, other than not enabling overflow checking.

Related information

F# Compiler version 11.0.0.0 for F# 5.0

  • Operating system: Windows 7 x64
  • .NET Runtime kind: .NET 5.0.4
  • Editing Tools: VS 2019, Rider

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI-thinks-issue-fixedArea-Compiler-Optionscompiler option processingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions