Skip to content

Commit 0d5af99

Browse files
authored
Port "Properly disallow yield in bodyless arrows" (#1825)
1 parent 8d7a88e commit 0d5af99

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

internal/parser/parser.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4324,6 +4324,7 @@ func (p *Parser) parseArrowFunctionExpressionBody(isAsync bool, allowReturnTypeI
43244324
}
43254325
saveContextFlags := p.contextFlags
43264326
p.setContextFlags(ast.NodeFlagsAwaitContext, isAsync)
4327+
p.setContextFlags(ast.NodeFlagsYieldContext, false)
43274328
node := p.parseAssignmentExpressionOrHigherWorker(allowReturnTypeInArrowFunction)
43284329
p.contextFlags = saveContextFlags
43294330
return node
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
YieldExpression20_es6.ts(3,8): error TS1163: A 'yield' expression is only allowed in a generator body.
2+
3+
4+
==== YieldExpression20_es6.ts (1 errors) ====
5+
function* test() {
6+
return () => ({
7+
b: yield 2, // error
8+
~~~~~
9+
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
10+
});
11+
}
12+

testdata/baselines/reference/submodule/conformance/YieldExpression20_es6.errors.txt.diff

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

0 commit comments

Comments
 (0)