Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sasmithjr opened this issue Aug 9, 2022 · 9 comments
Labels
Area-Compiler-StateMachines Sequence, list, task and other state machine compilation Bug
Milestone

Comments

@sasmithjr
Copy link

sasmithjr commented Aug 9, 2022

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.

@sasmithjr sasmithjr added the Bug label Aug 9, 2022
@edgarfgp
Copy link
Contributor

edgarfgp commented 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 ?

@TimLariviere
Copy link

TimLariviere commented 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.

@vzarytovskii
Copy link
Member

vzarytovskii commented 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.

@vzarytovskii vzarytovskii added the Area-Compiler-StateMachines Sequence, list, task and other state machine compilation label Aug 10, 2022
@vzarytovskii vzarytovskii added this to the Backlog milestone Aug 10, 2022
@sasmithjr sasmithjr changed the title FS3511 warning when using for...in in task CE with .NET SDK 6.0.400 FS3511 warning when using for...in in task CE with .NET SDK 6.0.400 in Release builds Aug 10, 2022
@sasmithjr
Copy link
Author

sasmithjr commented 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.

Correct about only in Release mode. I’m not sure how I wrote the whole bug report and didn’t explicitly state that but included the -c Release in the repro steps lol I edited the original issue to make that a smidge more clear.

@jcmrva
Copy link

jcmrva commented Aug 10, 2022

We have several functions with for ... in inside a Task CE, but only some of them are now getting the warning (an error in our project). I'm tempted to suppress it for the moment.

@Thorium
Copy link
Contributor

Thorium commented Aug 11, 2022

13415 is totally separate issue of this.

  • 13415 is a fix for the situation where F# did incorrect things (corrupt program state) when the warning FS3511 happens.
  • This issue is that the warning happens.

As Tim said this issue is not related to 6.0.400 and happened also before.

@dsyme
Copy link
Contributor

dsyme commented Aug 16, 2022

I'm closing as a duplicate of this: #12038

@cmeeren
Copy link
Contributor

cmeeren commented Sep 14, 2022

I'm also seeing this crop up in CI, whereas it wasn't there previously (for the same code). As the OP describes, this specifically happens when using for ... in in a task CE.

As Tim said this issue is not related to 6.0.400 and happened also before.

@TimLariviere said this happened in 6.0.303. @sasmithjr said in the OP that this did not happen with 6.0.302. There's no inconsistency; the behavior seems to have been introduced in 6.0.303.

I'm closing as a duplicate of this: #12038

Considering the above, how is this a duplicate of #12038? This has nothing to do with task CEs defined as top-level values. Edit: Oops, failed to read the OP example carefully enough, as well as my own code. It is indeed a top-level value in both cases. 😳 In any case, something evidently changed in 6.0.303, which was released long after #12038.

@sasmithjr
Copy link
Author

sasmithjr commented Sep 14, 2022

Sorry I didn't see that this got closed and couldn't follow up.

I'm closing as a duplicate of this: #12038

So that is an issue and it is the issue that I presented in my original comment, but it's actually not the issue I encountered in my actual codebase lol when I was trying to recreate a smaller version of the problem to reproduce it for this issue, I accidentally reproduced the top level issue and assumed it was the warning I was bumping in to in my codebase.

In my production code base, tasks (in functions in modules) with for ... in over arrays of tuples produce the warning. Repro code here.

It seems @cmeeren called out a warning with tuples in this comment. I'm not sure if it's the exact same issue, and I'm not sure if it's being explicitly tracked, though.

Want me to update this main comment in this issue for better tracking? Or don't worry about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-StateMachines Sequence, list, task and other state machine compilation Bug
Projects
Archived in project
Development

No branches or pull requests

8 participants