From f87e2e626fb224c41ed3eb6f6a6e1c34cace6210 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Wed, 23 Sep 2020 15:06:38 -0700 Subject: [PATCH 1/6] warning -> error for invalid underscore patterns --- src/QsCompiler/DataStructures/Diagnostics.fs | 3 +- .../DataStructures/Documentation.fs | 8 +-- .../DataStructures/ReservedKeywords.fs | 3 - src/QsCompiler/Tests.Compiler/SyntaxTests.fs | 58 ++++++++++--------- .../TextProcessor/QsFragmentParsing.fs | 3 +- src/QsCompiler/TextProcessor/SyntaxBuilder.fs | 13 ++--- 6 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/QsCompiler/DataStructures/Diagnostics.fs b/src/QsCompiler/DataStructures/Diagnostics.fs index 33134a187a..05061c7f30 100644 --- a/src/QsCompiler/DataStructures/Diagnostics.fs +++ b/src/QsCompiler/DataStructures/Diagnostics.fs @@ -325,7 +325,8 @@ type WarningCode = | DeprecatedANDoperator = 3302 | DeprecatedORoperator = 3303 | UseOfFutureReservedKeyword = 3304 - | UseOfUnderscorePattern = 3305 + | [] + UseOfUnderscorePattern = 3305 | DeprecatedRUSloopInFunction = 4001 | DiscardingItemInAssignment = 5001 diff --git a/src/QsCompiler/DataStructures/Documentation.fs b/src/QsCompiler/DataStructures/Documentation.fs index 6c307fa506..4ccb7993d7 100644 --- a/src/QsCompiler/DataStructures/Documentation.fs +++ b/src/QsCompiler/DataStructures/Documentation.fs @@ -44,7 +44,7 @@ type QsType with | QsTypeKind.Bool -> [ "# Summary" - "Represents a Boolean (true or false) value" + "Represents a Boolean (true or false) value." ] | QsTypeKind.String -> [ @@ -88,7 +88,7 @@ type QsType with [ "# Summary" "Represents a deterministic callable" - "that takes exacly one input argument of the type specified to the left of the arrow" + "that takes exactly one input argument of the type specified to the left of the arrow" "and returns one output value of the type specified to the right of the arrow." "The side effects and output value of a function are always fully defined by its input argument." ] @@ -110,9 +110,7 @@ type QsType with | QsTypeKind.UserDefinedType _ -> [ "# Summary" - "Represents a user defined type." - "User defined types consist of type name and a single item containing an object of their underlying type." - "The contained item can be accessed by applying the postfix unwrap operator \"!\"." + "Represents a user defined type. User defined types consist of named and anonymous items of different types." ] | QsTypeKind.TypeParameter _ -> [ diff --git a/src/QsCompiler/DataStructures/ReservedKeywords.fs b/src/QsCompiler/DataStructures/ReservedKeywords.fs index 492bf9c595..52e0de9a02 100644 --- a/src/QsCompiler/DataStructures/ReservedKeywords.fs +++ b/src/QsCompiler/DataStructures/ReservedKeywords.fs @@ -202,9 +202,6 @@ module InternalUse = "Borrow" "Return" - "Data" // REL0920: can be removed once we give errors for underscore patterns - "Item" // REL0920: can be removed once we give errors for underscore patterns - "QVoid" "Int64" "BigInteger" diff --git a/src/QsCompiler/Tests.Compiler/SyntaxTests.fs b/src/QsCompiler/Tests.Compiler/SyntaxTests.fs index 4846b284c9..b4f6f01247 100644 --- a/src/QsCompiler/Tests.Compiler/SyntaxTests.fs +++ b/src/QsCompiler/Tests.Compiler/SyntaxTests.fs @@ -25,48 +25,48 @@ let ``Reserved patterns`` () = ("_mySymbol" , true , Some "_mySymbol" , []) ("mySymbol_" , true , Some "mySymbol_" , []) ("my_symbol" , true , Some "my_symbol" , []) - ("my__symbol", true , Some "my__symbol", [Warning WarningCode.UseOfUnderscorePattern]) - ("__mySymbol", true , Some "__mySymbol", [Warning WarningCode.UseOfUnderscorePattern]) - ("mySymbol__", true , Some "mySymbol__", [Warning WarningCode.UseOfUnderscorePattern]) - ("__my__sym" , true , Some "__my__sym" , [Warning WarningCode.UseOfUnderscorePattern]) - ("my__sym__" , true , Some "my__sym__" , [Warning WarningCode.UseOfUnderscorePattern]) - ("__mysym__" , true , None , [Error ErrorCode.InvalidUseOfReservedKeyword]) + ("my__symbol", true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("__mySymbol", true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("mySymbol__", true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("__my__sym" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("my__sym__" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("__mysym__" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) ] |> List.iter (testOne (symbolNameLike ErrorCode.InvalidIdentifierName)) [ ("a.b" , true , ([Some "a" ], Some "b" ), []) ("_a.b" , true , ([Some "_a" ], Some "b" ), []) - ("a_.b" , true , ([Some "a_" ], Some "b" ), [Warning WarningCode.UseOfUnderscorePattern]) + ("a_.b" , true , ([None ], Some "b" ), [Error ErrorCode.InvalidUseOfUnderscorePattern]) ("a._b" , true , ([Some "a" ], Some "_b" ), []) ("a.b_" , true , ([Some "a" ], Some "b_" ), []) ("_a.b_" , true , ([Some "_a" ], Some "b_" ), []) - ("a_._b" , true , ([Some "a_" ], Some "_b" ), [Warning WarningCode.UseOfUnderscorePattern]) - ("__a.b" , true , ([Some "__a" ], Some "b" ), [Warning WarningCode.UseOfUnderscorePattern]) - ("a__a.b" , true , ([Some "a__a"], Some "b" ), [Warning WarningCode.UseOfUnderscorePattern]) - ("a__.b" , true , ([Some "a__" ], Some "b" ), [Warning WarningCode.UseOfUnderscorePattern]) - ("a.__b" , true , ([Some "a" ], Some "__b" ), [Warning WarningCode.UseOfUnderscorePattern]) - ("a.b__b" , true , ([Some "a" ], Some "b__b"), [Warning WarningCode.UseOfUnderscorePattern]) - ("a.b__" , true , ([Some "a" ], Some "b__" ), [Warning WarningCode.UseOfUnderscorePattern]) - ("__a.b__", true , ([Some "__a" ], Some "b__" ), [Warning WarningCode.UseOfUnderscorePattern; Warning WarningCode.UseOfUnderscorePattern]) + ("a_._b" , true , ([None ], Some "_b" ), [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("__a.b" , true , ([None ], Some "b" ), [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a__a.b" , true , ([None ], Some "b" ), [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a__.b" , true , ([None ], Some "b" ), [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a.__b" , true , ([Some "a" ], None ), [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a.b__b" , true , ([Some "a" ], None ), [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a.b__" , true , ([Some "a" ], None ), [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("__a.b__", true , ([None ], None ), [Error ErrorCode.InvalidUseOfUnderscorePattern; Error ErrorCode.InvalidUseOfUnderscorePattern]) ] |> List.iter (testOne (multiSegmentSymbol ErrorCode.InvalidIdentifierName |>> fst)) [ ("a.b" , true , Some "a.b" , []) ("_a.b" , true , Some "_a.b" , []) - ("a_.b" , true , Some "a_.b" , [Warning WarningCode.UseOfUnderscorePattern]) + ("a_.b" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) ("a._b" , true , Some "a._b" , []) - ("a.b_" , true , Some "a.b_" , [Warning WarningCode.UseOfUnderscorePattern]) - ("_a.b_" , true , Some "_a.b_" , [Warning WarningCode.UseOfUnderscorePattern]) - ("a_._b" , true , Some "a_._b" , [Warning WarningCode.UseOfUnderscorePattern]) - ("__a.b" , true , Some "__a.b" , [Warning WarningCode.UseOfUnderscorePattern]) - ("a__a.b" , true , Some "a__a.b" , [Warning WarningCode.UseOfUnderscorePattern]) - ("a__.b" , true , Some "a__.b" , [Warning WarningCode.UseOfUnderscorePattern]) - ("a.__b" , true , Some "a.__b" , [Warning WarningCode.UseOfUnderscorePattern]) - ("a.b__b" , true , Some "a.b__b" , [Warning WarningCode.UseOfUnderscorePattern]) - ("a.b__" , true , Some "a.b__" , [Warning WarningCode.UseOfUnderscorePattern]) - ("__a.b__", true , Some "__a.b__", [Warning WarningCode.UseOfUnderscorePattern; Warning WarningCode.UseOfUnderscorePattern]) + ("a.b_" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("_a.b_" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a_._b" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("__a.b" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a__a.b" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a__.b" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a.__b" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a.b__b" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("a.b__" , true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern]) + ("__a.b__", true , None , [Error ErrorCode.InvalidUseOfUnderscorePattern; Error ErrorCode.InvalidUseOfUnderscorePattern]) ] - |> List.iter (testOne (namespaceName |>> fst)) + |> List.iter (testOne (namespaceName |>> fst)) [] @@ -255,10 +255,14 @@ let ``Expression literal tests`` () = ("+0xfl", true, toBigInt "15", []); ("0xffl", true, toBigInt "255", []); ("+0xffl", true, toBigInt "255", []); + ("0o1", true, toInt 1, []); + ("+0o1", true, toInt 1, []); + ("-0o1", true, toExpr (NEG (toInt 1)), []); ("0b1", true, toInt 1, []); ("0b100", true, toInt 4, []); ("+0b100", true, toInt 4, []); ("-0b100", true, toExpr (NEG (toInt 4)), []); + (".1e-1", true, toExpr (DoubleLiteral 0.01), []); (".1", true, toExpr (DoubleLiteral 0.1), []); ("1.0", true, toExpr (DoubleLiteral 1.0), []); ("1.", true, toExpr (DoubleLiteral 1.0), []); diff --git a/src/QsCompiler/TextProcessor/QsFragmentParsing.fs b/src/QsCompiler/TextProcessor/QsFragmentParsing.fs index 2efb549c70..f43644eab5 100644 --- a/src/QsCompiler/TextProcessor/QsFragmentParsing.fs +++ b/src/QsCompiler/TextProcessor/QsFragmentParsing.fs @@ -68,8 +68,7 @@ let internal namespaceName = // internal for testing purposes let names = path @ [sym] let namespaceStr = names |> List.choose id |> String.concat "." if names |> List.contains None then (None, range) |> preturn - elif sym.Value.EndsWith "_" && not (namespaceStr.Contains "__" || namespaceStr.Contains "_.") then // REL0920: remove the second half and return None for pattern errors - buildWarning (preturn range) WarningCode.UseOfUnderscorePattern >>% (Some namespaceStr, range) + elif sym.Value.EndsWith "_" then buildError (preturn range) ErrorCode.InvalidUseOfUnderscorePattern >>% (None, range) else (Some namespaceStr, range) |> preturn multiSegmentSymbol ErrorCode.InvalidPathSegment >>= asNamespaceName diff --git a/src/QsCompiler/TextProcessor/SyntaxBuilder.fs b/src/QsCompiler/TextProcessor/SyntaxBuilder.fs index 59cea4e90c..0615f38a9a 100644 --- a/src/QsCompiler/TextProcessor/SyntaxBuilder.fs +++ b/src/QsCompiler/TextProcessor/SyntaxBuilder.fs @@ -342,16 +342,13 @@ let internal symbolNameLike errCode = |> identifier |> getRange let whenValid ((name : string, range), isBeforeDot) = - // REL0920: - // The warning for futureReservedUnderscorePattern should be replaced with an error in the future, - // and the first half of isReserved should be removed. - let futureReservedUnderscorePattern = name.Contains "__" || (isBeforeDot && name.EndsWith "_") - let isReserved = name.StartsWith "__" && name.EndsWith "__" || InternalUse.CsKeywords.Contains name - let isCsKeyword = SyntaxFacts.IsKeywordKind (SyntaxFacts.GetKeywordKind name) + let reservedUnderscorePattern = name.Contains "__" || (isBeforeDot && name.EndsWith "_") + let isReserved = InternalUse.CsKeywords.Contains + let isCsKeyword = SyntaxFacts.IsKeywordKind << SyntaxFacts.GetKeywordKind let moreThanUnderscores = name.TrimStart('_').Length <> 0 - if isCsKeyword || isReserved then buildError (preturn range) ErrorCode.InvalidUseOfReservedKeyword >>% None + if reservedUnderscorePattern then buildError (preturn range) ErrorCode.InvalidUseOfUnderscorePattern >>% None elif not moreThanUnderscores then buildError (preturn range) errCode >>% None - elif futureReservedUnderscorePattern then buildWarning (preturn range) WarningCode.UseOfUnderscorePattern >>% Some name + elif isReserved name || isCsKeyword name then buildError (preturn range) ErrorCode.InvalidUseOfReservedKeyword >>% None else preturn name |>> Some let invalid = let invalidName = pchar '\'' |> opt >>. manySatisfy isDigit >>. ident From 94c6f1c01212e0d3d5fea6be5f359cd1b8a4c7db Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Wed, 23 Sep 2020 15:19:58 -0700 Subject: [PATCH 2/6] error -> warning for entry point in library --- src/QsCompiler/Core/SymbolTable.fs | 2 +- src/QsCompiler/DataStructures/Diagnostics.fs | 7 +++++-- src/QsCompiler/Tests.Compiler/LinkingTests.fs | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/QsCompiler/Core/SymbolTable.fs b/src/QsCompiler/Core/SymbolTable.fs index 2489a3d8cb..4691ccd11a 100644 --- a/src/QsCompiler/Core/SymbolTable.fs +++ b/src/QsCompiler/Core/SymbolTable.fs @@ -984,7 +984,7 @@ and NamespaceManager // check that there is no more than one entry point, and no entry point if the project is not executable if signatureErrs.Any() then false, errs elif not isExecutable then - errs.Add (offset, range |> orDefault |> QsCompilerDiagnostic.Error (ErrorCode.EntryPointInLibrary, [])) + errs.Add (offset, range |> orDefault |> QsCompilerDiagnostic.Warning (WarningCode.EntryPointInLibrary, [])) false, errs else GetEntryPoints() |> Seq.tryHead |> function | None -> isExecutable, errs diff --git a/src/QsCompiler/DataStructures/Diagnostics.fs b/src/QsCompiler/DataStructures/Diagnostics.fs index 05061c7f30..9803b16087 100644 --- a/src/QsCompiler/DataStructures/Diagnostics.fs +++ b/src/QsCompiler/DataStructures/Diagnostics.fs @@ -247,7 +247,8 @@ type ErrorCode = | MissingEntryPoint = 6238 | InvalidEntryPointSpecialization = 6239 | DuplicateEntryPointArgumentName = 6240 - | EntryPointInLibrary = 6241 + | [] + EntryPointInLibrary = 6241 | InvalidTestAttributePlacement = 6242 | InvalidExecutionTargetForTest = 6243 | ExpectingFullNameAsAttributeArgument = 6244 @@ -325,7 +326,7 @@ type WarningCode = | DeprecatedANDoperator = 3302 | DeprecatedORoperator = 3303 | UseOfFutureReservedKeyword = 3304 - | [] + | [] UseOfUnderscorePattern = 3305 | DeprecatedRUSloopInFunction = 4001 @@ -343,6 +344,7 @@ type WarningCode = | IgnoredEntryPoint = 6203 | ReservedEntryPointArgumentName = 6204 | NonResultTypeReturnedInEntryPoint = 6205 + | EntryPointInLibrary = 6206 | GeneratorDirectiveWillBeIgnored = 6301 | UnreachableCode = 6302 @@ -740,6 +742,7 @@ type DiagnosticItem = | WarningCode.IgnoredEntryPoint -> "Entry point will be ignored. The project is a Q# library and cannot have any entry points." | WarningCode.ReservedEntryPointArgumentName -> "The argument name conflicts with a default argument for a Q# command line application." | WarningCode.NonResultTypeReturnedInEntryPoint -> "Only values of type Result, Result[], and tuples thereof can be returned when executing on a quantum processor." + | WarningCode.EntryPointInLibrary -> "Invalid entry point. Only executable Q# projects can have entry points. Entry point will be ignored. " | WarningCode.GeneratorDirectiveWillBeIgnored -> "Generation directive ignored. A specialization of this callable has been declared as intrinsic." | WarningCode.UnreachableCode -> "This statement will never be executed." diff --git a/src/QsCompiler/Tests.Compiler/LinkingTests.fs b/src/QsCompiler/Tests.Compiler/LinkingTests.fs index a90a29e2de..28ffa5a5fa 100644 --- a/src/QsCompiler/Tests.Compiler/LinkingTests.fs +++ b/src/QsCompiler/Tests.Compiler/LinkingTests.fs @@ -285,7 +285,7 @@ type LinkingTests (output:ITestOutputHelper) = for entryPoint in LinkingTests.ReadAndChunkSourceFile "ValidEntryPoints.qs" do this.CompileAndVerify compilationManager entryPoint [] - this.Expect "EntryPointInLibrary" [Error ErrorCode.EntryPointInLibrary] + this.Expect "EntryPointInLibrary" [Warning WarningCode.EntryPointInLibrary] [] From 7be4e478eac0cd95c1ea4d9603959f537be97499 Mon Sep 17 00:00:00 2001 From: bettinaheim <34236215+bettinaheim@users.noreply.github.com> Date: Wed, 23 Sep 2020 15:34:51 -0700 Subject: [PATCH 3/6] Update src/QsCompiler/DataStructures/Documentation.fs Co-authored-by: Guen P --- src/QsCompiler/DataStructures/Documentation.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QsCompiler/DataStructures/Documentation.fs b/src/QsCompiler/DataStructures/Documentation.fs index 4ccb7993d7..00182bf182 100644 --- a/src/QsCompiler/DataStructures/Documentation.fs +++ b/src/QsCompiler/DataStructures/Documentation.fs @@ -88,7 +88,7 @@ type QsType with [ "# Summary" "Represents a deterministic callable" - "that takes exactly one input argument of the type specified to the left of the arrow" + "that takes exactly one input argument of the type specified to the left of the arrow." "and returns one output value of the type specified to the right of the arrow." "The side effects and output value of a function are always fully defined by its input argument." ] From 7b4fb8d33b40c6d0e34b9967664568eecf091c48 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Wed, 23 Sep 2020 15:58:53 -0700 Subject: [PATCH 4/6] forgot to update a test --- src/QsCompiler/CompilationManager/TypeChecking.cs | 1 - src/QsCompiler/Tests.Compiler/TypeCheckingTests.fs | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/QsCompiler/CompilationManager/TypeChecking.cs b/src/QsCompiler/CompilationManager/TypeChecking.cs index 5277f42bb7..f346e78fa4 100644 --- a/src/QsCompiler/CompilationManager/TypeChecking.cs +++ b/src/QsCompiler/CompilationManager/TypeChecking.cs @@ -15,7 +15,6 @@ using Microsoft.Quantum.QsCompiler.SyntaxTree; using Microsoft.Quantum.QsCompiler.TextProcessing; using Microsoft.VisualStudio.LanguageServer.Protocol; -using Lsp = Microsoft.VisualStudio.LanguageServer.Protocol; using Position = Microsoft.Quantum.QsCompiler.DataTypes.Position; using Range = Microsoft.Quantum.QsCompiler.DataTypes.Range; diff --git a/src/QsCompiler/Tests.Compiler/TypeCheckingTests.fs b/src/QsCompiler/Tests.Compiler/TypeCheckingTests.fs index 208fdee678..c18439576f 100644 --- a/src/QsCompiler/Tests.Compiler/TypeCheckingTests.fs +++ b/src/QsCompiler/Tests.Compiler/TypeCheckingTests.fs @@ -101,10 +101,10 @@ type TypeCheckingTests () = this.Expect "OperationInequality" [Error ErrorCode.InvalidTypeInEqualityComparison] this.Expect "FunctionEquality" [Error ErrorCode.InvalidTypeInEqualityComparison] this.Expect "FunctionInequality" [Error ErrorCode.InvalidTypeInEqualityComparison] - this.Expect "InvalidTypeEquality" [ Error ErrorCode.InvalidUseOfReservedKeyword - Error ErrorCode.InvalidUseOfReservedKeyword ] - this.Expect "InvalidTypeInequality" [ Error ErrorCode.InvalidUseOfReservedKeyword - Error ErrorCode.InvalidUseOfReservedKeyword ] + this.Expect "InvalidTypeEquality" [ Error ErrorCode.InvalidUseOfUnderscorePattern + Error ErrorCode.InvalidUseOfUnderscorePattern ] + this.Expect "InvalidTypeInequality" [ Error ErrorCode.InvalidUseOfUnderscorePattern + Error ErrorCode.InvalidUseOfUnderscorePattern ] this.Expect "NoCommonBaseEquality" [ Error ErrorCode.ArgumentMismatchInBinaryOp Error ErrorCode.ArgumentMismatchInBinaryOp ] this.Expect "NoCommonBaseInequality" [ Error ErrorCode.ArgumentMismatchInBinaryOp From 9f894f8fbb1c461eefd84de13c040ae39bfb7caf Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 15 Oct 2020 14:44:29 -0700 Subject: [PATCH 5/6] properly check for warning --- src/QsCompiler/CompilationManager/ProjectManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/QsCompiler/CompilationManager/ProjectManager.cs b/src/QsCompiler/CompilationManager/ProjectManager.cs index 24defec15f..714e55c7d1 100644 --- a/src/QsCompiler/CompilationManager/ProjectManager.cs +++ b/src/QsCompiler/CompilationManager/ProjectManager.cs @@ -372,7 +372,7 @@ private void ReloadProjectReference(IDictionary projectOutputPaths, U (code, args) => diagnostics.Add(Errors.LoadError(code, args, MessageSource(this.ProjectFile)))); this.projectReferenceDiagnostics = this.projectReferenceDiagnostics.RemoveAll(d => - (d.Source == MessageSource(projectReference) && d.Code != WarningCode.DuplicateProjectReference.Code()) + (d.Source == MessageSource(projectReference) && d.IsWarning() && d.Code != WarningCode.DuplicateProjectReference.Code()) || DiagnosticTools.ErrorType(ErrorCode.ConflictInReferences)(d)) .Concat(diagnostics).ToImmutableArray(); this.Manager.PublishDiagnostics(this.CurrentLoadDiagnostics()); @@ -433,7 +433,7 @@ private void ReloadReferencedAssembly(Uri reference) (code, args) => diagnostics.Add(Errors.LoadError(code, args, MessageSource(this.ProjectFile)))); this.referenceDiagnostics = this.referenceDiagnostics.RemoveAll(d => - (d.Source == MessageSource(reference) && d.Code != WarningCode.DuplicateBinaryFile.Code()) + (d.Source == MessageSource(reference) && d.IsWarning() && d.Code != WarningCode.DuplicateBinaryFile.Code()) || DiagnosticTools.ErrorType(ErrorCode.ConflictInReferences)(d)) .Concat(diagnostics).ToImmutableArray(); this.Manager.PublishDiagnostics(this.CurrentLoadDiagnostics()); @@ -559,7 +559,7 @@ public Task ReloadSourceFileAsync(Uri sourceFile, Func this.loadedSourceFiles = this.loadedSourceFiles.Remove(sourceFile).Concat(loaded.Keys).ToImmutableHashSet(); this.sourceFileDiagnostics = this.sourceFileDiagnostics - .RemoveAll(d => d.Source == MessageSource(sourceFile) && d.Code != WarningCode.DuplicateSourceFile.Code()) + .RemoveAll(d => d.Source == MessageSource(sourceFile) && d.IsWarning() && d.Code != WarningCode.DuplicateSourceFile.Code()) .Concat(diagnostics).ToImmutableArray(); this.Manager.PublishDiagnostics(this.CurrentLoadDiagnostics()); From 4a9c3c97dbf5efc1361c91f1c244404a750816ed Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Thu, 15 Oct 2020 17:48:53 -0700 Subject: [PATCH 6/6] fixing an issue for header deserialization --- src/QsCompiler/Core/DeclarationHeaders.fs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/QsCompiler/Core/DeclarationHeaders.fs b/src/QsCompiler/Core/DeclarationHeaders.fs index 009c61846f..031a9b6aaf 100644 --- a/src/QsCompiler/Core/DeclarationHeaders.fs +++ b/src/QsCompiler/Core/DeclarationHeaders.fs @@ -45,8 +45,10 @@ module DeclarationHeader = inherit JsonConverter() override this.ReadJson(reader : JsonReader, objectType : Type, existingValue : Offset, hasExistingValue : bool, serializer : JsonSerializer) = - let offset = serializer.Deserialize(reader) - if Object.ReferenceEquals(offset, null) then Offset.Undefined else Offset.Defined offset + if reader.ValueType <> typeof || (string)reader.Value <> "Undefined" then + let offset = serializer.Deserialize(reader) + if Object.ReferenceEquals(offset, null) then Offset.Undefined else Offset.Defined offset + else Offset.Undefined override this.WriteJson(writer : JsonWriter, value : Offset, serializer : JsonSerializer) = match value with @@ -57,8 +59,10 @@ module DeclarationHeader = inherit JsonConverter() override this.ReadJson(reader : JsonReader, objectType : Type, existingValue : Range, hasExistingValue : bool, serializer : JsonSerializer) = - let range = serializer.Deserialize(reader) - if Object.ReferenceEquals(range, null) then Range.Undefined else Range.Defined range + if reader.ValueType <> typeof || (string)reader.Value <> "Undefined" then + let range = serializer.Deserialize(reader) + if Object.ReferenceEquals(range, null) then Range.Undefined else Range.Defined range + else Range.Undefined override this.WriteJson(writer : JsonWriter, value : Range, serializer : JsonSerializer) = match value with