fsharp
fsharp copied to clipboard
Internal error of single case active pattern within `let` binding
Repro steps
Input following code into fsi:
let (|T|) (f: _ -> _) = ();;
match id with T -> ();;
let (T) = id;;
Expected behavior
Both works.
Actual behavior
let way doesn't work.
Known workarounds
Use match.
Related information
Provide any related information (optional):
- Operating system: Windows 11
- .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET 9.0.100-preview.1.24101.2
- Editing Tools (e.g. Visual Studio Version, Visual Studio): Microsoft (R) F# Interactive version F# 8.0 的 12.8.300.0
Looking into this. I think this should not throw an internal error. Found a workaround to make this compile adding unit -> unit
let (|T|) (f: _ -> _) = ()
match id with T -> ()
let (T: unit -> unit) = id
Edit: this will also avoid the internal error
let (|T|) (f: unit -> unit) = f()
match id with T -> ()
let (T) = id
let (|T|) f = f()
match id with T c -> c
let (T) = id
cc @vzarytovskii