mirror of
				https://github.com/astral-sh/ruff.git
				synced 2025-10-29 19:17:20 +00:00 
			
		
		
		
	 d401a5440e
			
		
	
	
		d401a5440e
		
			
		
	
	
	
	
		
			
			We add support for `return` and `raise` statements in the control flow graph: we simply add an edge to the terminal block, push the statements to the current block, and proceed. This implementation will have to be modified somewhat once we add support for `try` statements - then we will need to check whether to _defer_ the jump. But for now this will do! Also in this PR: We fix the `unreachable` diagnostic range so that it lumps together consecutive unreachable blocks.
		
			
				
	
	
		
			18 lines
		
	
	
	
		
			297 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
	
		
			297 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| def only_return():
 | |
|     return
 | |
| 
 | |
| def after_return():
 | |
|     return 1
 | |
|     print("unreachable")
 | |
|     print("and this")
 | |
| 
 | |
| def after_raise():
 | |
|     raise ValueError
 | |
|     print("unreachable")
 | |
|     print("and this")
 | |
| 
 | |
| def multiple_returns():
 | |
|     return 1
 | |
|     print("unreachable")
 | |
|     return 2
 | |
|     print("and this")
 |