---
source: crates/ruff_linter/src/linter.rs
---
F704 `yield` statement outside of a function
 --> resources/test/fixtures/syntax_errors/yield_scope.py:1:1
  |
1 | yield  # error
  | ^^^^^
2 | yield 1  # error
3 | yield from 1  # error
  |

F704 `yield` statement outside of a function
 --> resources/test/fixtures/syntax_errors/yield_scope.py:2:1
  |
1 | yield  # error
2 | yield 1  # error
  | ^^^^^^^
3 | yield from 1  # error
4 | await 1  # error
  |

F704 `yield from` statement outside of a function
 --> resources/test/fixtures/syntax_errors/yield_scope.py:3:1
  |
1 | yield  # error
2 | yield 1  # error
3 | yield from 1  # error
  | ^^^^^^^^^^^^
4 | await 1  # error
5 | [(yield x) for x in range(3)]  # error
  |

F704 `await` statement outside of a function
 --> resources/test/fixtures/syntax_errors/yield_scope.py:4:1
  |
2 | yield 1  # error
3 | yield from 1  # error
4 | await 1  # error
  | ^^^^^^^
5 | [(yield x) for x in range(3)]  # error
  |

F704 `yield` statement outside of a function
 --> resources/test/fixtures/syntax_errors/yield_scope.py:5:3
  |
3 | yield from 1  # error
4 | await 1  # error
5 | [(yield x) for x in range(3)]  # error
  |   ^^^^^^^
  |

F704 `yield` statement outside of a function
  --> resources/test/fixtures/syntax_errors/yield_scope.py:23:9
   |
21 | def outer():
22 |     class C:
23 |         yield 1  # error
   |         ^^^^^^^
24 |
25 |     [(yield 1) for x in range(3)]  # error
   |

F704 `yield` statement outside of a function
  --> resources/test/fixtures/syntax_errors/yield_scope.py:25:7
   |
23 |         yield 1  # error
24 |
25 |     [(yield 1) for x in range(3)]  # error
   |       ^^^^^^^
26 |     ((yield 1) for x in range(3))  # error
27 |     {(yield 1) for x in range(3)}  # error
   |

F704 `yield` statement outside of a function
  --> resources/test/fixtures/syntax_errors/yield_scope.py:26:7
   |
25 |     [(yield 1) for x in range(3)]  # error
26 |     ((yield 1) for x in range(3))  # error
   |       ^^^^^^^
27 |     {(yield 1) for x in range(3)}  # error
28 |     {(yield 1): 0 for x in range(3)}  # error
   |

F704 `yield` statement outside of a function
  --> resources/test/fixtures/syntax_errors/yield_scope.py:27:7
   |
25 |     [(yield 1) for x in range(3)]  # error
26 |     ((yield 1) for x in range(3))  # error
27 |     {(yield 1) for x in range(3)}  # error
   |       ^^^^^^^
28 |     {(yield 1): 0 for x in range(3)}  # error
29 |     {0: (yield 1) for x in range(3)}  # error
   |

F704 `yield` statement outside of a function
  --> resources/test/fixtures/syntax_errors/yield_scope.py:28:7
   |
26 |     ((yield 1) for x in range(3))  # error
27 |     {(yield 1) for x in range(3)}  # error
28 |     {(yield 1): 0 for x in range(3)}  # error
   |       ^^^^^^^
29 |     {0: (yield 1) for x in range(3)}  # error
   |

F704 `yield` statement outside of a function
  --> resources/test/fixtures/syntax_errors/yield_scope.py:29:10
   |
27 |     {(yield 1) for x in range(3)}  # error
28 |     {(yield 1): 0 for x in range(3)}  # error
29 |     {0: (yield 1) for x in range(3)}  # error
   |          ^^^^^^^
   |

F704 `await` statement outside of a function
  --> resources/test/fixtures/syntax_errors/yield_scope.py:36:10
   |
35 |     class C:
36 |         [await x for x in range(3)]  # error, classes break async scope
   |          ^^^^^^^
37 |
38 |     lambda x: await x  # okay for now, lambda breaks _async_ scope but is a function
   |

F704 `await` statement outside of a function
  --> resources/test/fixtures/syntax_errors/yield_scope.py:41:1
   |
41 | await 1  # error
   | ^^^^^^^
   |
