core icon indicating copy to clipboard operation
core copied to clipboard

Add support for F# 8.0 features

Open Jand42 opened this issue 2 years ago • 2 comments

New language/FSharp.Core features: (See Announcing F# 8)

  • [x] Update to FSharp.Compiler.Service 43.8.100
  • _.Property shorthand (should be handled by FCS without AST change)
    • [x] Tests added
  • Nested record field copy and update (should be handled by FCS without AST change)
    • [x] Tests added
  • while! - syntax sugar handled by FCS, uses already existing Bind+While methods
    • [x] Tests added
  • [x] Extended string interpolation syntax - multiple $ now marks multiple { } needed. String interpolation macro needs to be updated
    • [x] Tests added
  • [x] Use and compose string literals for printf and related functions (probably handled by FCS and we can extract string literal the same way, needs to be tested)
    • [x] Tests added
  • Arithmetic operators in literals - do we translate expression or compute literal? Both should work, but latter is optimal.
    • [x] Tests added
  • Type constraint intersection syntax - type system upgrade, should have no effect on us, but add test to be sure
    • [x] Tests added
  • Extended fixed bindings - WS has no support for fixed, it's just ignored
  • Easier [<Extension>] method definition - syntax upgrade to test
    • [ ] Tests added
  • [x] Static members in interfaces - we already have support for same in C#, to bring over to F# ProjectReader
    • [x] Tests added
  • Static let in discriminated unions, records, structs, and types without primary constructors - should be handled by FCS but needs test. All static lets are hoisted to run on module initialization by F# semantics anyways
    • [x] Tests added
  • try-with within seq{},[] and [||] collection expressions - needs proxy for RuntimeHelpers.EnumerateTryWith and EnumerateFromFunctions
    • [x] Tests added

Jand42 avatar Dec 01 '23 08:12 Jand42

I don't think while! needs new proxies actually: it is desugared into a combination of existing methods Bind, While, and mutable variables. Ie an expression like

while! cond do
    action

is desugared as if it was written

let! x = cond
let mutable x' = x
while x' do
    action
    let! x = cond
    x' <- x

Tarmil avatar Dec 01 '23 10:12 Tarmil

@Tarmil Thanks! Indeed, TDD would have discovered this, I skipped testing while! for some reason while I checked what try-with within seq{} does. I have seen comparing methods in RuntimeHelpers that we also miss EnumerateFromFunctions, but I can't see in dotnet/fsharp where it's actually used yet... maybe deprecated?

Jand42 avatar Dec 01 '23 10:12 Jand42