fsprojects / fsprojects/FSharpLint

Parse error

Open
#479 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
F#
Stars
327
Forks
74
PR merge metrics
No merged PRs in 30d

Description

Description

When running the linting dotnet tool on my solution I get the following error

========== Linting <PATH_TO_FILE> ==========
Failed to parse file <PATH_TO_FILE>
Exception Message:
The exception has been reported. This internal exception should now be caught at an error recovery point on the stack. Original message: The type 'IQueryAmbient' is required here and is unavailable. You must add a reference to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.)
Exception Stack Trace:
   at FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.Error[b](ErrorLogger x, Exception exn) in F:\workspace\_work\1\s\src\fsharp\ErrorLogger.fs:line 397
   at FSharp.Compiler.Import.ImportTypeRefData(ImportMap env, range m, ILScopeRef scoref, String[] path, String typeName) in F:\workspace\_work\1\s\src\fsharp\import.fs:line 115
   at FSharp.Compiler.Import.ImportILTypeRefUncached(ImportMap env, range m, ILTypeRef tref) in F:\workspace\_work\1\s\src\fsharp\import.fs:line 138
   at FSharp.Compiler.Import.ImportILTypeRef(ImportMap env, range m, ILTypeRef tref) in F:\workspace\_work\1\s\src\fsharp\import.fs:line 148
   at FSharp.Compiler.Import.ImportILType(ImportMap env, range m, FSharpList`1 tinst, ILType ty) in F:\workspace\_work\1\s\src\fsharp\import.fs:line 172
   at FSharp.Compiler.Infos.itys@142-3.Invoke(ILType ity) in F:\workspace\_work\1\s\src\fsharp\infos.fs:line 144
   at Microsoft.FSharp.Primitives.Basics.List.chooseToFreshConsTail[a,b](FSharpList`1 cons, FSharpFunc`2 f, FSharpList`1 xs) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 178
   at Microsoft.FSharp.Primitives.Basics.List.choose[T,TResult](FSharpFunc`2 f, FSharpList`1 xs) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 193
   at FSharp.Compiler.Infos.GetImmediateInterfacesOfType(SkipUnrefInterfaces skipUnref, TcGlobals g, ImportMap amap, range m, TType ty) in F:\workspace\_work\1\s\src\fsharp\infos.fs:line 142
   at FSharp.Compiler.Infos.loop@176-50[a](Boolean followInterfaces, AllowMultiIntfInstantiations allowMultiIntfInst, SkipUnrefInterfaces skipUnref, FSharpFunc`2 visitor, TcGlobals g, ImportMap amap, range m, Int32 ndeep, TType ty, Tuple`3 _arg1) in F:\workspace\_work\1\s\src\fsharp\infos.fs:line 230
   at FSharp.Compiler.Infos.loop@176-51.Invoke(Int32 ndeep, TType ty, Tuple`3 _arg1) in F:\workspace\_work\1\s\src\fsharp\infos.fs:line 176
   at FSharp.Compiler.Infos.loop@176-50[a](Boolean followInterfaces, AllowMultiIntfInstantiations allowMultiIntfInst, SkipUnrefInterfaces skipUnref, FSharpFunc`2 visitor, TcGlobals g, ImportMap amap, range m, Int32 ndeep, TType ty, Tuple`3 _arg1) in F:\workspace\_work\1\s\src\fsharp\infos.fs:line 237
   at FSharp.Compiler.Infos.loop@176-51.Invoke(Int32 ndeep, TType ty, Tuple`3 _arg1) in F:\workspace\_work\1\s\src\fsharp\infos.fs:line 176
   at FSharp.Compiler.Infos.loop@176-50[a](Boolean followInterfaces, AllowMultiIntfInstantiations allowMultiIntfInst, SkipUnrefInterfaces skipUnref, FSharpFunc`2 visitor, TcGlobals g, ImportMap amap, range m, Int32 ndeep, TType ty, Tuple`3 _arg1) in F:\workspace\_work\1\s\src\fsharp\infos.fs:line 237
   at FSharp.Compiler.Infos.FoldHierarchyOfTypeAux[a](Boolean followInterfaces, AllowMultiIntfInstantiations allowMultiIntfInst, SkipUnrefInterfaces skipUnref, FSharpFunc`2 visitor, TcGlobals g, ImportMap amap, range m, TType ty, a acc) in F:\workspace\_work\1\s\src\fsharp\lib.fs:line 250
   at FSharp.Compiler.Infos.AllSuperTypesOfType(TcGlobals g, ImportMap amap, range m, AllowMultiIntfInstantiations allowMultiIntfInst, TType ty) in F:\workspace\_work\1\s\src\fsharp\infos.fs:line 273
   at FSharp.Compiler.Infos.AllInterfacesOfType(TcGlobals g, ImportMap amap, range m, AllowMultiIntfInstantiations allowMultiIntfInst, TType ty) in F:\workspace\_work\1\s\src\fsharp\infos.fs:line 277
   at <StartupCode$FSharp-Compiler-Service>.$Symbols.get_AllInterfaces@570.GenerateNext(IEnumerable`1& next) in F:\workspace\_work\1\s\src\fsharp\symbols\Symbols.fs:line 570
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl() in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\seqcore.fs:line 368
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at FSharp.Compiler.SourceCodeServices.FSharpEntity.get_AllInterfaces() in F:\workspace\_work\1\s\src\fsharp\symbols\Symbols.fs:line 569
   at FSharpLint.Rules.RedundantNewKeyword.doesNotImplementIDisposable@27-2.Invoke(FSharpEntity ctorForType) in D:\a\FSharpLint\FSharpLint\src\FSharpLint.Core\Rules\Conventions\RedundantNewKeyword.fs:line 28
   at FSharpLint.Rules.RedundantNewKeyword.doesNotImplementIDisposable@22-1.Invoke(FSharpOption`1 _arg1) in D:\a\FSharpLint\FSharpLint\src\FSharpLint.Core\Rules\Conventions\RedundantNewKeyword.fs:line 25
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, FSharpFunc`2 userCode, b result1) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 404
   at <StartupCode$FSharp-Compiler-Service>.$FSharpCheckerResults.clo@1792-276.Invoke(AsyncActivation`1 ctxt) in F:\workspace\_work\1\s\src\fsharp\service\FSharpCheckerResults.fs:line 1792
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 337
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronouslyInAnotherThread[a](CancellationToken token, FSharpAsync`1 computation, FSharpOption`1 timeout) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 851
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 888
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1142
   at FSharpLint.Application.Lint.lint(LintInfo lintInfo, FileParseInfo fileInfo) in D:\a\FSharpLint\FSharpLint\src\FSharpLint.Core\Application\Lint.fs:line 251

I have the same error when running the linting on the project containing the file BUT no error when running the linter on the file only.

Repro steps

I will try to create a reproducer but the file is pretty big so it might be a little hard for me to extract the right repro.

Expected behavior

No parse error or an error message which provides the "correct" fix.

Actual behavior

Error and actionnable message is not working. I have tried to add a reference to System.Xaml on this project but this does not change the problem.

Known workarounds

Skip file.

Related information
  • Operating system: Win 10
  • Branch: v 0.18.1
  • .NET Runtime, CoreCLR or Mono Version: net48
  • Performance information, links to performance testing scripts

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the project-level lint failure on Windows/net48 and compare it with linting the individual file. Trace the reported path through src/FSharpLint.Core/Rules/Conventions/RedundantNewKeyword.fs and src/FSharpLint.Core/Application/Lint.fs, then inspect the F# compiler symbol lookup in the stack trace. Done means the project lint either handles the missing System.Xaml reference correctly or reports a useful actionable error.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.