Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kerams opened this issue Feb 27, 2023 · 5 comments · Fixed by #15598
Closed

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

kerams opened this issue Feb 27, 2023 · 5 comments · Fixed by #15598
Labels
Area-Diagnostics mistakes and possible improvements to diagnostics Feature Improvement good first issue
Milestone

Comments

@kerams
Copy link
Contributor

kerams commented Feb 27, 2023

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
@edgarfgp
Copy link
Contributor

edgarfgp commented Jul 14, 2023

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 ?

@abonie
Copy link
Member

abonie commented Jul 14, 2023

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

@KevinRansom
Copy link
Member

This was introduced by this PR: #15214

@auduchinok
Copy link
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.

@auduchinok
Copy link
Member

auduchinok commented Jul 19, 2023

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
Labels
Area-Diagnostics mistakes and possible improvements to diagnostics Feature Improvement good first issue
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants