question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FS3511 warning when using `for...in` in task CE with .NET SDK 6.0.400 in Release builds

See original GitHub issue

In the latest SDK (6.0.400), I’m receiving a FS3511 warning with for...in loops in task when building for Release. This warning wasn’t present in previous SDKs (e.g. 6.0.302)

Repro steps

  1. In a new console application, replace Program.fs with the following code:
let v =
    task {
        for value in [1;2;3] do
            printfn $"{value}"
    }
    
printfn "Hello from F#"
  1. dotnet build -c Release

Can repro with https://github.com/sasmithjr/FS3511-repro-for..in

Expected behavior

Builds without warning

Actual behavior

Receive the warning warning FS3511: This state machine is not statically compilable. A resumable code invocation at '(2,4--2,8)' could not be reduced. An alternative dynamic implementation will be used, which may be slower. Consider adjusting your code to ensure this state machine is statically compilable, or else suppress this warning.

Known workarounds

Suppressing the warning or using collection iter functions.

Related information

  • Operating system: macOS 12.5 on an M1 MBP
  • .NET Runtime kind (.NET Core, .NET Framework, Mono) .NET Core, SDK 6.0.400

Thanks for the help, and please let me know if I can provide anymore info.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vzarytovskiicommented, Aug 10, 2022

Might be worth checking if this fixed in VS and VS4Mac 17.3 as I think there was a fix a similar code generation BUG see #13415 ?

No, I pretty sure it’s a different issue. But that fix might’ve caused it to break in .400.

1reaction
TimLarivierecommented, Aug 10, 2022

I encountered the exact same issue a few days ago, but it only shows up when I build in Release mode. Debug mode doesn’t seem to give me any warning.

Tried today building against dotnet 6.0.303 and 6.0.400. Both have the same behavior: no warning in debug build, warning FS3511 in release mode because of for .. in .. do inside a task.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NETSDK1045: The current .NET SDK does not support ...
This error occurs when the build tools can't find the version of the .NET SDK that's needed to build a project. This is...
Read more >
The current .NET SDK does not support targeting . ...
I want to create a class library project with Target Framework .NET Standard 2.0. I've updated my Visual Studio 2017 to Version 15.3...
Read more >
Fixing build warning NETSSDK1138 when ...
This warning appears when you're building a project which uses a .NET Core version which was no longer supported when the .NET SDK...
Read more >
Fixing: Unable to locate the .NET Core SDK. Check that it is ...
This error can happen when the defined version of the .NET Core SDK differs from the configured value when running the dotnet tools....
Read more >
Solution to Visual Studio 2022 messing up ...
The error shown when attempting to load the projects was: The project file cannot be opened. Unable to locate the .NET SDK. Check...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found