Skip to content

Commit

Permalink
Fix inline io parsing with mixins
Browse files Browse the repository at this point in the history
When there was no space between the `:=` and `with` tokens when
parsing an inline io statement, for example:
```
operation Foo {
  input :=with [Bar] {}
}
```
the parser would skip the `with` and so not realize its parsing a
mixin, failing when it sees a `[` instead of a `{`. This was due
to an extra call to `tokenizer.next()`, which skipped the `with`.
Usually the `next()` would just skip the space before the `with`,
but when the space wasn't present it skipped the `with`.

The inline-io test was updated to include this case.
  • Loading branch information
milesziemer committed Apr 26, 2023
1 parent 11fee39 commit 72b87a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,8 @@ private void parseOperationStatement(ShapeId id, SourceLocation location) {
case "input":
IdlToken nextInput = tokenizer.expect(IdlToken.COLON, IdlToken.WALRUS);
tokenizer.next();
// tokenizer.skipSpaces();
IdlToken curr = tokenizer.getCurrentToken();
IdlTraitParser.Result inputTrait = new IdlTraitParser.Result(
InputTrait.ID.toString(), Node.objectNode(), IdlTraitParser.TraitType.ANNOTATION);
parseInlineableOperationMember(id, nextInput, operationInputSuffix, builder::input, inputTrait);
Expand Down Expand Up @@ -1083,7 +1085,6 @@ private void parseInlineableOperationMember(
}
// Remove any pending, invalid docs that may have come before the inline shape.
tokenizer.removePendingDocCommentLines();
tokenizer.next();
// don't skip docs here in case there are docs on the inlined structure.
tokenizer.skipWs();
consumer.accept(parseInlineStructure(id.getName() + suffix, defaultTrait));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ structure NameBearer {
}

operation UsesMixins {
input := with [NameBearer] {
// Parser handles weird/missing SP
input :=with [NameBearer] {
id: String
}

Expand Down

0 comments on commit 72b87a5

Please sign in to comment.