parser: fix function return anon_fn without parentheses
							parent
							
								
									504fd01f57
								
							
						
					
					
						commit
						73296e486a
					
				|  | @ -219,7 +219,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl { | ||||||
| 	mut end_pos := p.prev_tok.position() | 	mut end_pos := p.prev_tok.position() | ||||||
| 	// Return type
 | 	// Return type
 | ||||||
| 	mut return_type := table.void_type | 	mut return_type := table.void_type | ||||||
| 	if p.tok.kind.is_start_of_type() { | 	if p.tok.kind.is_start_of_type() || (p.tok.kind == .key_fn && p.tok.line_nr == p.prev_tok.line_nr) { | ||||||
| 		end_pos = p.tok.position() | 		end_pos = p.tok.position() | ||||||
| 		return_type = p.parse_type() | 		return_type = p.parse_type() | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -144,3 +144,14 @@ fn test_fn_type_call() { | ||||||
| 	} | 	} | ||||||
| 	assert st1.f(10) == 1010 | 	assert st1.f(10) == 1010 | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | fn ff() fn () int { | ||||||
|  | 	return fn () int { | ||||||
|  | 		return 22 | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | fn test_fn_return_fn() { | ||||||
|  | 	f := ff() | ||||||
|  | 	assert f() == 22 | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue