std::future<T>::wait returns compile error in msvc

Using the msvc with the /std::c++20 flag on, I can't seem to get the wait call compiled.

simple example:


std::future<int> fut = std::async([](){return 0;});

with error:

<source>(4): error C3927: '->': trailing return type is not allowed after a non-function declarator
<source>(4): error C3484: syntax error: expected '->' before the return type
<source>(4): error C3613: missing return type after '->' ('int' assumed)
<source>(4): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
<source>(4): error C2371: 'fut': redefinition; different basic types
<source>(3): note: see declaration of 'fut'
<source>(4): error C2146: syntax error: missing ';' before identifier 'wait'

compiler explorer:

What am I missing here? why doesn't this compile?

edit: As kindly pointed out by 康桓瑋 and G.M. the code was written in a filescope, which is not allowed.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum