checker: fix ui struct init error with default field value is const variable (#13215)
							parent
							
								
									4e0e2ef753
								
							
						
					
					
						commit
						edf0bc365c
					
				| 
						 | 
					@ -330,11 +330,17 @@ 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 {
 | 
				
			||||||
 | 
											if field.default_expr is ast.StructInit {
 | 
				
			||||||
							idx := c.table.find_type_idx(field.default_expr.typ_str)
 | 
												idx := c.table.find_type_idx(field.default_expr.typ_str)
 | 
				
			||||||
							if idx != 0 {
 | 
												if idx != 0 {
 | 
				
			||||||
								info.fields[i].default_expr_typ = ast.new_type(idx)
 | 
													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