Skip to content
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
4 changes: 2 additions & 2 deletions internal/checker/grammarchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (c *Checker) grammarErrorAtPos(nodeForSourceFile *ast.Node, start int, leng
func (c *Checker) grammarErrorOnNode(node *ast.Node, message *diagnostics.Message, args ...any) bool {
sourceFile := ast.GetSourceFileOfNode(node)
if !c.hasParseDiagnostics(sourceFile) {
c.diagnostics.Add(NewDiagnosticForNode(node, message, args...))
c.error(node, message, args...)
return true
}
return false
Expand Down Expand Up @@ -1841,7 +1841,7 @@ func (c *Checker) checkGrammarForDisallowedBlockScopedVariableStatement(node *as
default:
panic("Unknown BlockScope flag")
}
return c.grammarErrorOnNode(node.AsNode(), diagnostics.X_0_declarations_can_only_be_declared_inside_a_block, keyword)
c.error(node.AsNode(), diagnostics.X_0_declarations_can_only_be_declared_inside_a_block, keyword)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
disallowedBlockScopedInPresenceOfParseErrors1.ts(5,5): error TS1156: 'const' declarations can only be declared inside a block.
disallowedBlockScopedInPresenceOfParseErrors1.ts(6,17): error TS2454: Variable 'e' is used before being assigned.
disallowedBlockScopedInPresenceOfParseErrors1.ts(8,1): error TS1128: Declaration or statement expected.
disallowedBlockScopedInPresenceOfParseErrors1.ts(12,5): error TS1156: 'let' declarations can only be declared inside a block.
disallowedBlockScopedInPresenceOfParseErrors1.ts(13,17): error TS2454: Variable 'e' is used before being assigned.
disallowedBlockScopedInPresenceOfParseErrors1.ts(15,1): error TS1128: Declaration or statement expected.
disallowedBlockScopedInPresenceOfParseErrors1.ts(21,5): error TS1156: 'using' declarations can only be declared inside a block.
disallowedBlockScopedInPresenceOfParseErrors1.ts(22,17): error TS2454: Variable 'e' is used before being assigned.
disallowedBlockScopedInPresenceOfParseErrors1.ts(24,1): error TS1128: Declaration or statement expected.
disallowedBlockScopedInPresenceOfParseErrors1.ts(30,5): error TS1156: 'await using' declarations can only be declared inside a block.
disallowedBlockScopedInPresenceOfParseErrors1.ts(31,17): error TS2454: Variable 'e' is used before being assigned.
disallowedBlockScopedInPresenceOfParseErrors1.ts(33,1): error TS1128: Declaration or statement expected.


==== disallowedBlockScopedInPresenceOfParseErrors1.ts (8 errors) ====
==== disallowedBlockScopedInPresenceOfParseErrors1.ts (12 errors) ====
// https://github.com/microsoft/TypeScript/issues/61734

function f1() {
if (1 > 0)
const e = 3;
~~~~~~~~~~~~
!!! error TS1156: 'const' declarations can only be declared inside a block.
console.log(e);
~
!!! error TS2454: Variable 'e' is used before being assigned.
Expand All @@ -25,6 +31,8 @@ disallowedBlockScopedInPresenceOfParseErrors1.ts(33,1): error TS1128: Declaratio
function f2() {
if (1 > 0)
let e = 3;
~~~~~~~~~~
!!! error TS1156: 'let' declarations can only be declared inside a block.
console.log(e);
~
!!! error TS2454: Variable 'e' is used before being assigned.
Expand All @@ -38,6 +46,8 @@ disallowedBlockScopedInPresenceOfParseErrors1.ts(33,1): error TS1128: Declaratio
function f3() {
if (1 > 0)
using e = resource;
~~~~~~~~~~~~~~~~~~~
!!! error TS1156: 'using' declarations can only be declared inside a block.
console.log(e);
~
!!! error TS2454: Variable 'e' is used before being assigned.
Expand All @@ -51,6 +61,8 @@ disallowedBlockScopedInPresenceOfParseErrors1.ts(33,1): error TS1128: Declaratio
async function f4() {
if (1 > 0)
await using e = asyncResource;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1156: 'await using' declarations can only be declared inside a block.
console.log(e);
~
!!! error TS2454: Variable 'e' is used before being assigned.
Expand Down

This file was deleted.