A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
You are running the RTM version of SQL 2019. There have been many bug fixes related to the inlining of scalar functions and you should download and install the most recent cumulative update, CU17.
...however, this particular issue has not been fixed. I was able to repro the error on SQL 2019 CU17.
A workaround is to turn off inlining by adding WITH INLINE=OFF after RETURNS INT.