-
Notifications
You must be signed in to change notification settings - Fork 854
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBug
Milestone
Description
Consider the following program:
type SensorReadings = int
type EngineError<'e> =
static abstract Overheated : 'e
static abstract LowOil : 'e
let startEngine<'e when EngineError<'e>> (sensorReading : SensorReadings) : Result<unit, 'e> =
if sensorReading <= 10 then Error 'e.Overheated
elif sensorReading <= 20 then Error 'e.LowOil
else Ok ()
type AudioError<'e> =
static abstract DeviceNotPaired : 'e
let initializeAudio<'e when AudioError<'e>> (sensorReading : SensorReadings) : Result<unit, 'e> =
if sensorReading <= 30 then Error 'e.DeviceNotPaired else Ok ()
type CarError2 =
| Overheated2
| LowOil2
| DeviceNotPaired2
interface EngineError<CarError2> with
static member Overheated = Overheated2
static member LowOil = LowOil2
// There seems to be a compiler bug here. An interesting error is produced very late during
// building if "2" is removed from DU constructor names. I expect it to be possible to
// reuse the names, as normally possible in F#.
interface AudioError<CarError2> with
static member DeviceNotPaired = DeviceNotPaired2
let startCar (sensorReading : SensorReadings) : Result<unit, CarError2> = result {
// Prioritize engine errors above audio errors
do! startEngine sensorReading
do! initializeAudio sensorReading
}Note the "2" in the naming of DU constructors and the note above. When leaving the "2"s out, Visual Studio does not provide any feed-back (warning, etc.) so everything seems OK. However, building produces the following seemingly very low-level error:
Build started...
1>------ Build started: Project: IWSAMDemo, Configuration: Debug Any CPU ------
1>FSC : error FS2014: A problem occurred writing the binary 'obj\Debug\net7.0\refint\IWSAMDemo.dll': Error in pass2 for type ErrorMerging, error: Error in pass2 for type CarError2, error: duplicate entry 'Overheated' in property table
1>Done building project "IWSAMDemo.fsproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:01,464 ==========
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBug
Type
Projects
Status
New