Skip to content

Commit 7d78f2c

Browse files
committed
it can be return type of operations
1 parent 6f9191f commit 7d78f2c

File tree

7 files changed

+77
-19
lines changed

7 files changed

+77
-19
lines changed

lib/productions/iterable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ export class IterableLike extends Base {
7474
tokens.async &&
7575
tokens.base.value === "iterable"
7676
) {
77-
// Instead of a missing semicolon, this could be an invalid async iterable
78-
// return type for a regular operation. Let's bail out early in that case.
77+
// Instead of a missing semicolon, this could be an async iterable return
78+
// type for a regular operation. Let's bail out early in that case.
7979
tokeniser.unconsume(start_position);
8080
return;
8181
} else if (!tokens.termination) {

lib/productions/operation.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,6 @@ export class Operation extends Base {
6969
}
7070
if (this.idlType) {
7171
yield* this.idlType.validate(defs);
72-
if (this.idlType.generic === "async iterable") {
73-
const message = `Operations can not return ${this.idlType.generic} types.`;
74-
yield validationError(
75-
this.tokens.name,
76-
this,
77-
"operation-return-invalid-type",
78-
message,
79-
);
80-
}
8172
}
8273
for (const argument of this.arguments) {
8374
yield* argument.validate(defs);

test/invalid/baseline/invalid-operation-return.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
callback DoSomething = Promise<DOMString> (async iterable<DOMString> bool);
1+
callback DoSomething = Promise<DOMString> (async iterable<DOMString> bool);

test/invalid/idl/invalid-operation-return.webidl

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/syntax/baseline/async-iterable-type.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,75 @@
124124
"extAttrs": [],
125125
"partial": false
126126
},
127+
{
128+
"type": "interface",
129+
"name": "asyncIterableReturn",
130+
"inheritance": null,
131+
"members": [
132+
{
133+
"type": "operation",
134+
"name": "stream",
135+
"idlType": {
136+
"type": "return-type",
137+
"extAttrs": [],
138+
"generic": "async iterable",
139+
"nullable": false,
140+
"union": false,
141+
"idlType": [
142+
{
143+
"type": "return-type",
144+
"extAttrs": [],
145+
"generic": "",
146+
"nullable": false,
147+
"union": false,
148+
"idlType": "short"
149+
}
150+
]
151+
},
152+
"arguments": [
153+
{
154+
"type": "argument",
155+
"name": "foo",
156+
"extAttrs": [],
157+
"idlType": {
158+
"type": "argument-type",
159+
"extAttrs": [],
160+
"generic": "async iterable",
161+
"nullable": false,
162+
"union": false,
163+
"idlType": [
164+
{
165+
"type": "argument-type",
166+
"extAttrs": [],
167+
"generic": "",
168+
"nullable": false,
169+
"union": false,
170+
"idlType": "short"
171+
}
172+
]
173+
},
174+
"default": null,
175+
"optional": false,
176+
"variadic": false
177+
}
178+
],
179+
"extAttrs": [],
180+
"special": ""
181+
}
182+
],
183+
"extAttrs": [
184+
{
185+
"type": "extended-attribute",
186+
"name": "Exposed",
187+
"rhs": {
188+
"type": "identifier",
189+
"value": "Window"
190+
},
191+
"arguments": []
192+
}
193+
],
194+
"partial": false
195+
},
127196
{
128197
"type": "eof",
129198
"value": ""

test/syntax/idl/async-iterable-type.webidl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ interface Canvas {
55
interface I {
66
Promise<undefined> f1(async iterable<[XAttr] float> arg);
77
};
8+
9+
[Exposed=Window]
10+
interface asyncIterableReturn {
11+
async iterable<short> stream(async iterable<short> foo);
12+
};

0 commit comments

Comments
 (0)