-
Notifications
You must be signed in to change notification settings - Fork 834
Open
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBug
Milestone
Description
Repro steps
Compile and run this with dotnet run
module A =
[<Literal>]
let B = 42m
[<EntryPoint>]
let main args =
0
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<AssemblyName>Test</AssemblyName>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
</Project>
results in
Unhandled exception. System.InvalidProgramException: Common Language Runtime detected an invalid program.
at <StartupCode$Test>.$Program..cctor()
at Program.main(String[] args) in .../Program.fs:line 7
Note that it works in release mode with dotnet run -c Release
.
Comparing the generated IR between debug and release of $Program::.cctor
shows
Debug
.method private specialname rtspecialname static
void .cctor () cil managed
{
// Method begins at RVA 0x2070
// Header size: 12
// Code size: 17 (0x11)
.maxstack 2
.locals init (
[0] valuetype [System.Runtime]System.Decimal
)
...
}
Release
.method private specialname rtspecialname static
void .cctor () cil managed
{
// Method begins at RVA 0x2070
// Header size: 1
// Code size: 17 (0x11)
.maxstack 8
...
}
Expected behavior
Should not throw exception.
Actual behavior
Throws exception.
Known workarounds
Remove [<Literal>]
attribute or use release build.
Related information
Provide any related information (optional):
Reproduces on 9.0.200, 9.0.301, 9.0.303, 9.0.305, 10.0.100-rc.
Metadata
Metadata
Assignees
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBug
Type
Projects
Status
New