Skip to content

Commit

Permalink
Use expectTokenIsOneOf
Browse files Browse the repository at this point in the history
  • Loading branch information
daviwil committed Jun 1, 2022
1 parent da3349a commit 124d36a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/compiler/core/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,13 @@ export function parse(code: string | SourceFile, options: ParseOptions = {}): Ca
const id = parseIdentifier();
const templateParameters = inInterface ? [] : parseTemplateParameterList();

// Make sure the next token is one that is expected
const token = expectTokenIsOneOf(Token.OpenParen, Token.Colon);

// Check if we're parsing a declaration or reuse of another operation
let signature: OperationSignature;
const signaturePos = tokenPos();
if (token() === Token.OpenParen) {
if (token === Token.OpenParen) {
const parameters = parseOperationParameters();
parseExpected(Token.Colon);
const returnType = parseExpression();
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/test/checker/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe("cadl: operations", () => {
expectDiagnostics(diagnostics, [
{
code: "token-expected",
message: `':' expected.`,
message: `'(', or ':' expected.`,
},
{
code: "token-expected",
Expand Down

0 comments on commit 124d36a

Please sign in to comment.