FSharpLint
FSharpLint copied to clipboard
Parse error
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 [email protected](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 [email protected](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 [email protected](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>[email protected](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>[email protected](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
Thank you for the report!
Looks like it's related to resolving dependencies, unfortunately likely a little further up the stack but potentially may have been fixed upstream already. I'll try to take a look
I'm thinking this is also potentially a case where we don't want to be failing fast, this should probably be handled - we have some logic for linting without types which it should probably fall back to (this is what you're seeing when you lint a file alone as we don't have the dependency info when operating on just a file)
I think it's going to be a little too complex to reduce the problem. Is there a way for me to somehow run your parser in debug mode and see where is the crash? I'd like to help but not sure how else I could do so.