checker: fix goto label with comptime tmpl (#12853)
							parent
							
								
									2b981b011e
								
							
						
					
					
						commit
						c44115c67d
					
				|  | @ -30,6 +30,7 @@ fn (mut c Checker) comptime_call(mut node ast.ComptimeCall) ast.Type { | ||||||
| 	} | 	} | ||||||
| 	if node.is_vweb { | 	if node.is_vweb { | ||||||
| 		// TODO assoc parser bug
 | 		// TODO assoc parser bug
 | ||||||
|  | 		save_cur_fn := c.table.cur_fn | ||||||
| 		pref_ := *c.pref | 		pref_ := *c.pref | ||||||
| 		pref2 := &pref.Preferences{ | 		pref2 := &pref.Preferences{ | ||||||
| 			...pref_ | 			...pref_ | ||||||
|  | @ -56,6 +57,8 @@ fn (mut c Checker) comptime_call(mut node ast.ComptimeCall) ast.Type { | ||||||
| 		c.nr_warnings += c2.nr_warnings | 		c.nr_warnings += c2.nr_warnings | ||||||
| 		c.nr_errors += c2.nr_errors | 		c.nr_errors += c2.nr_errors | ||||||
| 		c.nr_notices += c2.nr_notices | 		c.nr_notices += c2.nr_notices | ||||||
|  | 
 | ||||||
|  | 		c.table.cur_fn = save_cur_fn | ||||||
| 	} | 	} | ||||||
| 	if node.method_name == 'html' { | 	if node.method_name == 'html' { | ||||||
| 		rtyp := c.table.find_type_idx('vweb.Result') | 		rtyp := c.table.find_type_idx('vweb.Result') | ||||||
|  |  | ||||||
|  | @ -36,3 +36,19 @@ pub fn test_goto_after_return() { | ||||||
| 	finally_ok: | 	finally_ok: | ||||||
| 	assert true | 	assert true | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | fn test_goto_with_comptime_tmpl() { | ||||||
|  | 	a := 22 | ||||||
|  | 	_ := $tmpl('./tmpl/a.txt') | ||||||
|  | 	println('before goto') | ||||||
|  | 
 | ||||||
|  | 	unsafe { | ||||||
|  | 		goto label | ||||||
|  | 	} | ||||||
|  | 	println('failed goto') | ||||||
|  | 	assert false | ||||||
|  | 
 | ||||||
|  | 	label: | ||||||
|  | 	println('goto label') | ||||||
|  | 	assert true | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue