Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/QsCompiler/DataStructures/Diagnostics.fs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ type WarningCode =
| UseOfFutureReservedKeyword = 3304
| [<Obsolete("This diagnostic is no longer in use. The error InvalidUseOfUnderscorePattern is given instead.")>] UseOfUnderscorePattern = 3305
| DeprecatedTupleBrackets = 3306
| DeprecatedKeyword = 3307
| DeprecatedRUSloopInFunction = 4001

| DiscardingItemInAssignment = 5001
Expand Down Expand Up @@ -893,6 +894,7 @@ type DiagnosticItem =
"Double underscores as well as underscores before a dot or at the end of a namespace name will be reserved for internal use in the future."
| WarningCode.DeprecatedTupleBrackets ->
"Deprecated syntax. Parentheses here are no longer required and will not be supported in the future."
| WarningCode.DeprecatedKeyword -> "The \"{0}\" keyword is deprecated. Use the \"{1}\" keyword instead."
| WarningCode.DeprecatedRUSloopInFunction ->
"The use of repeat-until-success-loops within functions may not be supported in the future. Please use a while-loop instead."

Expand Down
9 changes: 9 additions & 0 deletions src/QsCompiler/DataStructures/ReservedKeywords.fs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@ module Statements =
let Apply = "apply"

/// keyword for a Q# allocation statement
let Use = "use"

/// keyword for a Q# allocation statement
[<Obsolete "This keyword will be replaced by Use.">]
let Using = "using"

/// keyword for a Q# allocation statement
let Borrow = "borrow"

/// keyword for a Q# allocation statement
[<Obsolete "This keyword will be replaced by Borrow.">]
let Borrowing = "borrowing"


Expand Down
69 changes: 66 additions & 3 deletions src/QsCompiler/Tests.Compiler/CompletionParsingTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ open Microsoft.Quantum.QsCompiler.SyntaxTokens
open Microsoft.Quantum.QsCompiler.TextProcessing.CodeCompletion
open Microsoft.Quantum.QsCompiler.TextProcessing.CodeCompletion.FragmentParsing


let private matches scope previous (text, expected) =
match GetCompletionKinds scope previous text with
| Success actual ->
Expand Down Expand Up @@ -75,7 +74,15 @@ let private callableStatement =
let private functionStatement = callableStatement @ [ Keyword "while" ]

let private operationStatement =
callableStatement @ [ Keyword "repeat"; Keyword "using"; Keyword "borrowing"; Keyword "within" ]
callableStatement
@ [
Keyword "repeat"
Keyword "use"
Keyword "using"
Keyword "borrow"
Keyword "borrowing"
Keyword "within"
]

let private operationTopLevelStatement =
operationStatement @ [ Keyword "body"; Keyword "adjoint"; Keyword "controlled" ]
Expand Down Expand Up @@ -500,7 +507,34 @@ let ``Operation statement parser tests`` () =
[
("repeat ", [])
("within ", [])
("using ", [])
("use ", [ Declaration ])
("use q ", [])
("use q =", [ Keyword "Qubit" ])
("use q = Qubit", [ Keyword "Qubit" ])
("use q = Qubit(", [])
("use q = Qubit()", [])
("use q = Qubit[", expression)
("use q = Qubit[5", [])
("use q = Qubit[5]", [])
("use q = Qubit[n", expression)
("use q = Qubit[n ", infix)
("use q = Qubit[n +", expression)
("use q = Qubit[n +1", [])
("use q = Qubit[n +x", expression)
("use q = Qubit[n + ", expression)
("use q = Qubit[n + 1", [])
("use q = Qubit[n + 1]", [])
("use (", [ Declaration ])
("use (q,", [ Declaration ])
("use (q, r)", [])
("use (q, r) =", [ Keyword "Qubit" ])
("use (q, r) = (", [ Keyword "Qubit" ])
("use (q, r) = (Qubit(", [])
("use (q, r) = (Qubit()", [])
("use (q, r) = (Qubit(),", [ Keyword "Qubit" ])
("use (q, r) = (Qubit(), Qubit()", [])
("use (q, r) = (Qubit(), Qubit())", [])
("using ", [ Declaration ])
("using (", [ Declaration ])
("using (q ", [])
("using (q =", [ Keyword "Qubit" ])
Expand Down Expand Up @@ -531,6 +565,34 @@ let ``Operation statement parser tests`` () =
("using ((q, r) = (Qubit(),", [ Keyword "Qubit" ])
("using ((q, r) = (Qubit(), Qubit()", [])
("using ((q, r) = (Qubit(), Qubit())", [])
("using ((q, r) = (Qubit(), Qubit()))", [])
("borrow ", [ Declaration ])
("borrow q ", [])
("borrow q =", [ Keyword "Qubit" ])
("borrow q = Qubit", [ Keyword "Qubit" ])
("borrow q = Qubit(", [])
("borrow q = Qubit()", [])
("borrow q = Qubit[", expression)
("borrow q = Qubit[5", [])
("borrow q = Qubit[5]", [])
("borrow q = Qubit[n", expression)
("borrow q = Qubit[n ", infix)
("borrow q = Qubit[n +", expression)
("borrow q = Qubit[n +1", [])
("borrow q = Qubit[n +x", expression)
("borrow q = Qubit[n + ", expression)
("borrow q = Qubit[n + 1]", [])
("borrow (", [ Declaration ])
("borrow (q,", [ Declaration ])
("borrow (q, r)", [])
("borrow (q, r) =", [ Keyword "Qubit" ])
("borrow (q, r) = (", [ Keyword "Qubit" ])
("borrow (q, r) = (Qubit(", [])
("borrow (q, r) = (Qubit()", [])
("borrow (q, r) = (Qubit(),", [ Keyword "Qubit" ])
("borrow (q, r) = (Qubit(), Qubit()", [])
("borrow (q, r) = (Qubit(), Qubit())", [])
("borrowing ", [ Declaration ])
("borrowing (", [ Declaration ])
("borrowing (q ", [])
("borrowing (q =", [ Keyword "Qubit" ])
Expand Down Expand Up @@ -560,6 +622,7 @@ let ``Operation statement parser tests`` () =
("borrowing ((q, r) = (Qubit(),", [ Keyword "Qubit" ])
("borrowing ((q, r) = (Qubit(), Qubit()", [])
("borrowing ((q, r) = (Qubit(), Qubit())", [])
("borrowing ((q, r) = (Qubit(), Qubit()))", [])
]

testElifElse Operation (Value(IfClause { Expression = InvalidExpr; Range = Null }))
Expand Down
Loading