Skip to content

Inaccurate error in anonymous record copy-and-update #14814

Closed

Description

@kerams

Repro steps

let t3 (t1: {| gu: string; ff: int |}) = { t1 with ff = 3 }

or sharplab.

Expected behavior

Error saying brace-pipes are required.

Actual behavior

Squiggly under ff with The record label 'ff' is not defined..

Related information

  • VSIX for F# built from main
  • VS 17.6 Preview 1

Activity

  1. added
    Area-Diagnostics
    on Feb 27, 2023
  2. added this to the Backlog milestone on Feb 27, 2023
  3. edgarfgp commented on Jul 14, 2023

    @edgarfgp
    Contributor

    I tried fixing this on #15598 and quickly realized there seemed to be an unexpected internal error while executing the following test. Which blocks any further attempt to improve the error reporting on anonymous records :(

    Unexpected exception raised in compiler: destAppTy (Failure)

     [<Fact>]
         let ``This expression was expected to have an anonymous Record but has a record`` () =
             Fsx """
     let t3 (t1: {| gu: string; ff: int |}) = { t1 with ff = 3 }
             """
             |> ignoreWarnings
             |> typecheck
             |> shouldFail
    System.AggregateException: One or more errors occurred. (One or more errors occurred. (Unknown exception seen in compiler: JetBrains.ReSharper.TestRun...
    
    System.AggregateException
    One or more errors occurred. (One or more errors occurred. (Unknown exception seen in compiler: JetBrains.ReSharper.TestRunner.Logging.TraceListener+AssertionException: Unknown exception seen in compiler: JetBrains.ReSharper.TestRunner.Logging.TraceListener+AssertionException: Unknown exception seen in compiler: JetBrains.ReSharper.TestRunner.Logging.TraceListener+AssertionException: Unknown exception seen in compiler: JetBrains.ReSharper.TestRunner.Logging.TraceListener+AssertionException: Unknown exception seen in compiler: JetBrains.ReSharper.TestRunner.Logging.TraceListener+AssertionException: Unknown exception seen in compiler: JetBrains.ReSharper.TestRunner.Logging.TraceListener+AssertionException: Unexpected exception raised in compiler: destAppTy (Failure)
    

    @abonie Does this ring a bell based on #15519 ?

  4. abonie commented on Jul 14, 2023

    @abonie
    Member

    Hmm... I don't expect these are related

  5. KevinRansom commented on Jul 19, 2023

    @KevinRansom
    Contributor

    This was introduced by this PR: #15214

  6. auduchinok commented on Jul 19, 2023

    @auduchinok
    Member

    This was introduced by this PR: #15214

    @KevinRansom That sounds suspicious, because #15214 was merged in May, and I can reproduce this problem using .NET SDK 6.0.100 which was released in November 2021 and in .NET SDK 7.0.101.

    eugene@Eugenes-Air:ConsoleApp30$ dotnet --version
    6.0.100
    
    eugene@Eugenes-Air:ConsoleApp30$ dotnet build
    Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
    Copyright (C) Microsoft Corporation. All rights reserved.
    
      Determining projects to restore...
      Restored /Users/eugene/RiderProjects/ConsoleApp30/ConsoleApp30/ConsoleApp30.fsproj (in 158 ms).
    /Users/eugene/RiderProjects/ConsoleApp30/ConsoleApp30/Program.fs(2,52): error FS0039: The record label 'ff' is not defined. [/Users/eugene/RiderProjects/ConsoleApp30/ConsoleApp30/ConsoleApp30.fsproj]
    
    Build FAILED.
    
    /Users/eugene/RiderProjects/ConsoleApp30/ConsoleApp30/Program.fs(2,52): error FS0039: The record label 'ff' is not defined. [/Users/eugene/RiderProjects/ConsoleApp30/ConsoleApp30/ConsoleApp30.fsproj]
        0 Warning(s)
        1 Error(s)
    
    Time Elapsed 00:00:01.66
    

    I didn't try it on other versions.

  7. auduchinok commented on Jul 19, 2023

    @auduchinok
    Member

    Off-topic: I wonder if we could enable the normal record syntax for anon records too?

    RFC says this:

    Unlike records, we do not assume that the origExpr has the same type as the overall expression.

    For some reason I thought it was already allowed, and when the normal record syntax is used, an anonymous record of the same type would be produced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-DiagnosticsFeature Improvementgood first issue

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions