checker: fix ui struct init error with default field value is const variable (#13215)
							parent
							
								
									4e0e2ef753
								
							
						
					
					
						commit
						edf0bc365c
					
				|  | @ -330,10 +330,16 @@ pub fn (mut c Checker) struct_init(mut node ast.StructInit) ast.Type { | ||||||
| 					continue | 					continue | ||||||
| 				} | 				} | ||||||
| 				if field.has_default_expr { | 				if field.has_default_expr { | ||||||
| 					if field.default_expr is ast.StructInit && field.default_expr_typ == 0 { | 					if field.default_expr_typ == 0 { | ||||||
| 						idx := c.table.find_type_idx(field.default_expr.typ_str) | 						if field.default_expr is ast.StructInit { | ||||||
| 						if idx != 0 { | 							idx := c.table.find_type_idx(field.default_expr.typ_str) | ||||||
| 							info.fields[i].default_expr_typ = ast.new_type(idx) | 							if idx != 0 { | ||||||
|  | 								info.fields[i].default_expr_typ = ast.new_type(idx) | ||||||
|  | 							} | ||||||
|  | 						} else { | ||||||
|  | 							if const_field := c.table.global_scope.find_const('$field.default_expr') { | ||||||
|  | 								info.fields[i].default_expr_typ = const_field.typ | ||||||
|  | 							} | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| 					continue | 					continue | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue