@@ -470,24 +470,28 @@ let private valueArray =
470470 <|> bracketDefinedCommaSepExpr ( lArray, rArray)
471471
472472/// Parses a Q# array declaration as QsExpression.
473- /// Raises an InvalidContructorExpression if the array declaration keyword is not followed by a valid array constructor,
473+ /// Adds an InvalidConstructorExpression if the array declaration keyword is not followed by a valid array constructor,
474474/// and advances to the next whitespace character or QsFragmentHeader.
475475let private newArray =
476476 let itemType = expectedQsType ( lArray >>% ()) >>= fun itemType -> validateTypeSyntax true itemType >>% itemType
477477 let body = itemType .>>. ( arrayBrackets ( expectedExpr eof) |>> fst) |>> NewArray
478478
479+ let toExpr headRange ( kind , bodyRange ) =
480+ QsExpression.New( kind, Range.Span headRange bodyRange)
481+
479482 let invalid =
480483 checkForInvalid
481484 ( qsFragmentHeader >>% " " <|> ( nextCharSatisfies Text.IsWhitespace >>. emptySpace))
482485 ErrorCode.InvalidConstructorExpression
483486 >>% unknownExpr
484487
485488 let withWarning ( expr : QsExpression ) =
486- // TODO: Diagnostic range doesn't cover the entire expression.
487489 let range = expr.Range |> QsNullable.defaultValue Range.Zero
488490 QsCompilerDiagnostic.Warning ( WarningCode.DeprecatedNewArray, []) range |> pushDiagnostic >>% expr
489491
490- arrayDecl.parse >>. ( term body |>> QsExpression.New <|> ( term invalid |>> fst)) >>= withWarning
492+ arrayDecl.parse
493+ >>= fun headRange -> term body |>> toExpr headRange <|> ( term invalid |>> fst)
494+ >>= withWarning
491495
492496/// used to temporarily store item accessors for both array item and named item access expressions
493497type private ItemAccessor =
0 commit comments