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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/compiler",
"comment": "Fix: Compiler freeze when using invalid token between doc comment and type",
"type": "none"
}
],
"packageName": "@typespec/compiler"
}
3 changes: 2 additions & 1 deletion packages/compiler/src/core/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,7 @@ function createParser(code: string | SourceFile, options: ParseOptions = {}): Pa

const items: T[] = [];
while (true) {
const startingPos = tokenPos();
const { pos, docs, directives, decorators } = parseAnnotations({
skipParsingDocNodes: Boolean(kind.invalidAnnotationTarget),
});
Expand Down Expand Up @@ -2670,7 +2671,7 @@ function createParser(code: string | SourceFile, options: ParseOptions = {}): Pa
parseExpected(kind.delimiter);
}

if (pos === tokenPos()) {
if (startingPos === tokenPos()) {
// Error recovery: we've inserted everything during this loop iteration
// and haven't made any progress. Assume that the current token is a bad
// representation of the end of the the list that we're trying to get
Expand Down
1 change: 1 addition & 0 deletions packages/compiler/test/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ describe("compiler: parser", () => {
describe("recovery", () => {
parseErrorEach([
[`model M { ]`, [/Property expected/]],
[`model M { /** */ */ prop: string }`, [/Property expected/]],
[
`
@dec1 @dec2 import "foo";
Expand Down