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.

Inline functions might not be recompiled properly

See original GitHub issue

Apologies if this has been reported before, I couldn’t find it in other issues.

Changing strings in inline functions don’t seem to always be recompiled. Other changes does get recompiled.

Repro steps

Create solution with a console app and a class library:

open lib

Say.hello "there"
namespace lib

module Say =
    let inline hello name =
        printfn "Hello %s" name

Changes to the string in hello don’t apply when doing a dotnet run on the console app.

Expected behavior

Class library to be recompiled.

Actual behavior

~/dev/playground/InlineBug/console
λ dotnet run
Hello there
~/dev/playground/InlineBug/console
λ /bin/cat ../lib/Library.fs
namespace lib

module Say =
    let inline hello name =
        printfn "Bye %s" name
~/dev/playground/InlineBug/console
λ dotnet run
Hello there

Known workarounds

Doing a dotnet clean before dotnet run works.

Related information

Provide any related information (optional):

Operating system:

λ sw_vers
ProductName:		macOS
ProductVersion:		13.4.1
BuildVersion:		22F82

.NET SDK version:

7.0.306

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sualitucommented, Jul 25, 2023

Great work, fantastic! I’m glad to hear it’s already been fixed, and I’ll be looking forward to it being released in net8. And thanks a bunch for the workaround as well.

1reaction
T-Grocommented, Jul 25, 2023

Repro works on my end as well, not related to macOS.

  • Does not matter weather the function is inline or not

  • Repros both net7 as well net8

  • It does get fixed when I add the <ProduceReferenceAssembly>false</ProduceReferenceAssembly> item to lib’s .fsproj!

  • Independently, it also does get fixed when I add the -c Release switch to dotnet run

  • When I add the -c Debug, it does not update

=> It is a combination of ProduceReferenceAssembly=true and Configuration=Debug (fsc.exe is then called with --optimize-)

What I also tested:

  • I locally build the compiler tools from main
  • I added the following Directory.Build.props to make use of them for dotnet run:
<Project>
    <PropertyGroup>  
        <DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath>
        <FscToolPath>$([System.IO.Path]::GetDirectoryName('$(DOTNET_HOST_PATH)'))</FscToolPath>
        <FscToolExe >dotnet.exe</FscToolExe>
        <DotnetFscCompilerPath>D:\fsharp\artifacts\bin\fsc\Release\net7.0\fsc.dll</DotnetFscCompilerPath>
    </PropertyGroup>  
</Project>

  • With that, I verified that latest main correctly detects change:
    • for unspecified dotnet run
    • for dotnet run -c Debug
    • for dotnet run -c Release

=> A workaround for now is to use <ProduceReferenceAssembly>false</ProduceReferenceAssembly>. The next update of the net8 sdk will also include the change which fixes this behavior.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - inline functions returning incorrect results
No, inlined functions are (of course) required to have the same results as non-inlined functions. So, the problem must be somewhere else, in...
Read more >
"inline" functions are being wrongly eliminated · Issue #6144
I noticed the below issue using emscrption 1.37.29 (Win10, 64-bit portable version, fetched from here: https://github.com/juj/emsdk).
Read more >
Inline Functions, C++ FAQ
Do inline functions improve performance? ¶ Δ ... Yes and no. Sometimes. Maybe. There are no simple answers. inline functions might make the...
Read more >
Inline Functions in C++
Does C++ compiler create default constructor when we write our own? ... Why C++ is partially Object Oriented Language? ... C++ Function Overloading....
Read more >
Recompile inline function
Hello,. I'm having a problem with a inline table function : CREATE FUNCTION dbo.udf_func (@id int). RETURNS TABLE AS RETURN (. SELECT v....
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